Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.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 2:TemplateDoesNotExist即使文件放置正确_Python_Django_Django Templates - Fatal编程技术网

Python Django 2:TemplateDoesNotExist即使文件放置正确

Python Django 2:TemplateDoesNotExist即使文件放置正确,python,django,django-templates,Python,Django,Django Templates,我在Django 2上遇到了一个有趣的问题 在我的settings.py中,我写了以下内容: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': {

我在Django 2上遇到了一个有趣的问题

在我的
settings.py
中,我写了以下内容:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
之后,我在我的项目根文件夹中创建了文件夹
模板

然后我创建了名为
front
的应用程序,并将其添加到我的
设置中。py
已安装的应用程序

在我的
视图.py中,我添加了以下视图:

def index(request):
    return render(request, 'front/index')
我已将其url分配如下:

url(r'^$', views.index, name='index'),
当我尝试访问此视图时,出现以下错误:

TemplateDoesNotExist at /
front/index
为什么会这样?我错过什么了吗?

改变

def index(request):
    return render(request, 'front/index')

def index(request):
    return render(request, 'front/index.html')