Django 渲染函数如何知道这个文件的位置?
How does a django render function know where this file is located?
是的,所以我正在关注一个很长的 python Django 教程,但我对此感到困惑
渲染函数知道 index.html 在哪里。我所在的文件是 views.py.
from django.shortcuts import render
from appTwo.forms import NewUserForm
def index(request):
return render(request,'appTwo/index.html')
文件结构如下
它本身并不“知道”,但它会按照 here 所述扫描您在 settings.py 中列出的所有模板目录。使用与您提供的名称匹配的第一个名称。
是的,所以我正在关注一个很长的 python Django 教程,但我对此感到困惑 渲染函数知道 index.html 在哪里。我所在的文件是 views.py.
from django.shortcuts import render
from appTwo.forms import NewUserForm
def index(request):
return render(request,'appTwo/index.html')
文件结构如下
它本身并不“知道”,但它会按照 here 所述扫描您在 settings.py 中列出的所有模板目录。使用与您提供的名称匹配的第一个名称。