Duncan
Duncan

Reputation: 257

Django 2.2. Instead of my template django uses the standard

I created an authapp application in django. And I registered it in settings and added to the main urls.py:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('authapp/', include('authapp.urls', namespace='authapp')),
]

In authapp/urls.py I added:

from django.contrib.auth import views as auth_views
from django.urls import path, reverse_lazy

import authapp.views as authapp

app_name = 'authapp'

urlpatterns = [
    path('password_change/', auth_views.PasswordChangeView.as_view(success_url=reverse_lazy('authapp:password_change_done')), name='password_change'),
    path('password_change/done/', auth_views.PasswordChangeDoneView.as_view(), name='password_change_done'),
]

I added my templates to authapp/templates/registration:
- password_change_form.html
- password_change_done.html
But when you click on the link http://127.0.0.1:8000/authapp/password_change/ I get to standart form in the django admin, not my form...
What am I doing wrong?

Upvotes: 0

Views: 174

Answers (2)

Duncan
Duncan

Reputation: 257

The problem was solved.
It's need just put authapp app above standart admin app in settings.py.

INSTALLED_APPS = [
    ...
    'authapp',
    'django.contrib.admin',
    ...
]

Upvotes: 2

lgigek
lgigek

Reputation: 100

You have do specify your template directory in DIRS, as in the following snippet:

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [BASE_DIR + "/templates/registration/"],
        "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",
            ]
        },
    }
]

This should be configured in settings.py.

See: https://docs.djangoproject.com/en/2.2/topics/templates/#configuration

Upvotes: 0

Related Questions