Custom password_reset_form.html not rendered

Hi
I would require some help.
Im new to django and Im building website, that will use the Django authorization management.

I have created an app accounts is to manage everything related to the users.
Inside of this app I have a folder
templates\registration

Inside of that i have templates:
login.html
password_change_form.html
password_change_done.html
password_reset_form.html
password_reset_done.html

The urls.py in the accounts app includes:
urlpatterns = [
path(‘accounts/’, include(“django.contrib.auth.urls”)),
]

and the main urls.py
urlpatterns = [
path(‘’, include(‘accounts.urls’)),
path(‘register/’, views.register, name=“register”),
path(‘admin/’, admin.site.urls),
]

What is bodering me is that the login.html is rendered normally from the custom template, while the password_change and password_reset forms are ignored and the page redirects to the default admin page.
Any ideas what I’m missing?

Thanks for the help
Jure

Don’t know if you’ve found your answer yet or not, but a quick search of the documentation leads me to believe that you need to override the individual URLs for the password change process to specify that your own templates are to be used.

See the documentation on Authentication Views.

Hi Ken

Thx for the tip. It does kind a work with a custom individual URL, still after the form is submitted form the redirection goes to the admin password_change/done page.

According to this tutorial you should be able to simply replace the templates with custom ones with no additional URLs specified.

https://learndjango.com/tutorials/django-password-reset-tutorial

And my login.html template does work like that :frowning:
The other password related templates are not which is frustrating.

Any ideas.
Thx and best regards
Jure

Cool! I learned something new here.

One of the key items with it working the way described is that the templates must reside in a directory named “registration”, and you must make the settings file change to include your project-level “templates” directory in the DIRS option. Once this is done, then it should locate your registration pages before the app-based templates are found.

Ken

Hi Ken,

Yes i figured it out also now. The templates folder needs to be in the project root folder not inside of the app templates.
Works now like a charm :smiley:

Thx for the help
Jure

2 Likes

I had the same problem, and it solved by putting the app that handle authentication (in your case “accounts”) at the beginning (first place) of the INSTALLED_APPS list in the setting.py file. As you point out custom login file page can be called from the inside of the app templates/registration folder and you may want to keep all your files in the same place.

4 Likes

I’m having the same issue and I’ve tried multiple ways recommend. Any other ideas to resolve the issue.

1 Like

This is a very old thread. You might get better visibility for your issue if you open a new topic with the details of your situation.

This advice solved my issue totally!

Thank you!!!

I’m answering on this thread even if it’s quite old as I also stumbled upon this issue and Google brought me here.

As in most projects the own app gets added at the end of the INSTALLED_APPS setting, I solved in with the following setup:

project urls.py

urlpatterns = [
    path('admin/', admin.site.urls),
    path("accounts/", include("accounts.urls")),
    path("accounts/", include("django.contrib.auth.urls")),
]

app urls.py

urlpatterns = [
    path("register/", SignUpView.as_view(), name="register"),
]

customized template password_reset_form.html was placed in directory templates/registration where template is located in the root directory like project folder and app folder accounts

eu só renomeei de password_reset_form.html para password_reset_form1.html
pronto e direcionei o urls.py para password_reset_form1.html dai ele não pega mais o formulario padrao é isso boa sorte.