Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django渲染函数如何知道该文件的位置?_Python_Django_Filesystems - Fatal编程技术网

Python django渲染函数如何知道该文件的位置?

Python 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

好的,所以我正在学习一个很长的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')
文件结构看起来像

它本身并不“知道”,但它会扫描您在settings.py中列出的所有模板目录,如前所述。将使用与您提供的名称匹配的第一个名称。

因为1。
settings.py
和2中有一个模板根目录设置。你告诉它,
'appTwo/index.html'
等等,我是个傻瓜!我忘了我把模板目录加入了标准的基本目录。