Ad
TemplateDoesNotExist, Registration/login.html Django
Am using Django Authentication Model. The problem is when i visit /accounts/login, i get TemplateDoesNotExist: registration/login.html error message. Now the problem is i already specified a template for the LoginView.
Here is my accounts/urls.py file
from django.urls import path
from django.contrib.auth import views as auth_views
from . import views
app_name = 'accounts'
urlpatterns = [
path('login/',auth_views.LoginView.as_view(template_name='accounts/login.html'), name='login'),
path('join/', views.SignupView.as_view(), name='join'),
path('logout/', auth_views.LogoutView.as_view(), name='logout'),
]
The login template is located at accounts/templates/accounts/login.html
And here is the TEMPLATES
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',
],
},
},
]
My projects urls.py file has these
path('accounts/', include('django.contrib.auth.urls')),
path('accounts/', include('accounts.urls')),
Ad
Answer
From your error message, it is expecting the login.html
file is to be located within your accounts
app templates/registration
directory like this: accounts/templates/registration/login.html
. That should fix your issue.
Also, add these two lines at the bottom of your settings.py
file:
LOGIN_URL = 'login'
LOGOUT_URL = 'logout'
Ad
source: stackoverflow.com
Related Questions
- → Django, code inside <script> tag doesn't work in a template
- → Uncaught ReferenceError: Parent is not defined
- → React - Django webpack config with dynamic 'output'
- → Put a Rendered Django Template in Json along with some other items
- → Implement shopify templates in django
- → Python Shopify API output formatted datetime string in django template
- → How to avoid being crawled/penalized by Google
- → Django: Identify the urls that provide duplicate content and set a canonical link
- → Shopify app: adding a new shipping address via webhook
- → Jquery Modal Confirmation on Django form submit for deletion of object
- → changing the size of an image with css
- → shopify_auth multi store session handling
- → How to use Shopify Python API RecurringApplicationCharge
Ad