Python django渲染函数如何知道该文件的位置?
好的,所以我正在学习一个很长的python Django教程,我不知道这是怎么回事 render函数知道index.html在哪里。我所在的文件是views.pyPython django渲染函数如何知道该文件的位置?,python,django,filesystems,Python,Django,Filesystems,好的,所以我正在学习一个很长的python Django教程,我不知道这是怎么回事 render函数知道index.html在哪里。我所在的文件是views.py from django.shortcuts import render from appTwo.forms import NewUserForm def index(request): return render(request,'appTwo/index.html') 文件结构看起来像 它本身并不“知道”,但它会扫描您在s
from django.shortcuts import render
from appTwo.forms import NewUserForm
def index(request):
return render(request,'appTwo/index.html')
文件结构看起来像
它本身并不“知道”,但它会扫描您在settings.py中列出的所有模板目录,如前所述。将使用与您提供的名称匹配的第一个名称。因为1。
settings.py
和2中有一个模板根目录设置。你告诉它,'appTwo/index.html'
等等,我是个傻瓜!我忘了我把模板目录加入了标准的基本目录。