Password view form in Django format

I'm still new to Django and ask a few questions about how inline viewing works. I noticed that djang has a built-in password change view on django.contrib.auth.views.password_change. This view shows the admin site against the background of the template, while I want to provide my own CSS / template, but retain the form and functionality of this view. How can I do it? You can pass something to urls.py

r'password_change/$', 'django.contrib.auth.views.password_change') 

How is the user template? I'm not sure how to do it right.

+6
source share
3 answers

You can specify the template to be used by specifying the template_name argument:

 (r'password_change/$', 'django.contrib.auth.views.password_change', {'template_name': 'path/to/password_reset.html'}) 

In your template, make sure that you use the provided template variable {{ form }} and you are good to go.

+11
source

Django will try to download the templates first from your application and then backtrack. So, to override the templates for contrib.auth, you just need to:

  • Create a directory named auth in the templates directory.
  • Create a template with the same name that expects to wait for the inline view.
  • There is no step 3.
+6
source

You can also specify the URL of the successful change with:

 url(r'^password/$', 'django.contrib.auth.views.password_change', {'post_change_redirect' : '/password-changed/','template_name': 'password.html'},), 
0
source

All Articles