Почему я получаю TemplateDoesNotExist в /accounts/login/?
Я пытаюсь установить мои представления аутентификации на моем сайте locallibrary и вот мои коды :
В файле urls.py моего проекта есть следующее
from django.contrib import admin
from django.urls import path, include, re_path
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('catalog/', include('catalog.urls')),
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += [
path(r'^accounts/', include('django.contrib.auth.urls')),
re_path(r'^accounts/', include('django.contrib.auth.urls')),
]
шаблоны :
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['./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',
],
},
},
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [str(BASE_DIR.joinpath("templates"))], # this points templates in the root directory
'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',
],
},
},
]
теперь внутри папки templates
$ ls -al templates/registrations
|
|--login.html
|--password_change_done.html
|
|...
Это должно решить вашу проблему! Создайте папку Templates в корневом каталоге и внутри нее папку регистрации
$ sudo mkdir -p templates/registrations
Также то, что сказал @whatwillem-van-onsem