Python 模板在/accounts/login处不存在

Python 模板在/accounts/login处不存在,python,django,django-registration,Python,Django,Django Registration,我使用django注册对用户进行身份验证。我确实通过pip安装了django注册,并添加到settings.py文件中。然而,它仍然给我的模板不存在错误。以下是错误: TemplateDoesNotExist at /accounts/login/ registration/login.html Request Method: GET Request URL: http://127.0.0.1:8000/accounts/login/?next=/ Django Versio

我使用django注册对用户进行身份验证。我确实通过pip安装了django注册,并添加到settings.py文件中。然而,它仍然给我的模板不存在错误。以下是错误:

 TemplateDoesNotExist at /accounts/login/
 registration/login.html
 Request Method:    GET
 Request URL:   http://127.0.0.1:8000/accounts/login/?next=/
 Django Version:    1.11.3
 Exception Type:    TemplateDoesNotExist
 Exception Value:   registration/login.html
 Exception Location:    C:\Python34\lib\site-     packages\django\template\loader.py in select_template, line 53
代码如下:

from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth.views import login, logout
from chat.views import index
from django.conf.urls import include

urlpatterns = [
    url('^', include('django.contrib.auth.urls')),
    url(r'^admin/', admin.site.urls),
    url(r'^$',index, name='homepage'),  # The start point for index view
    url(r'^accounts/login/$', login, name='login'),  # The base django login view
    url(r'^accounts/logout/$', logout, name='logout'),  # The base django logout view
在settings.py文件中:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.humanize',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'chat',
    'registration',
]

似乎templates文件夹位于根目录下,因此您需要将设置更改为该文件夹

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            BASE_DIR + '/templates/',
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
                # list of context processors

            ],
            'debug': True
        },
    },
]

在settings.py中,需要添加模板路径。