gpt4 book ai didi

python - 模板不存在于/accounts/login

转载 作者:行者123 更新时间:2023-12-01 02:47:51 24 4
gpt4 key购买 nike

我正在使用 django-registraion 进行用户身份验证。我确实通过 pip 安装了 django-registration 并添加到了 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',
]

This is the structure of my django project.

最佳答案

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

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
},
},
]

关于python - 模板不存在于/accounts/login,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45095752/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com