1

This may seem like a stupid question, but how does one use the included Grappelli's templates?

For example, I would like to use the password_reset.html and associated templates (password_reset_email.html, etc). What is the path to them? Also, are the routes such as password_reset_done included or do I have to implement admin specific routes to use the included templates (I have already done it for the part of the application that is not admin related).

          url(
              r'^admin/password_reset/$',
              'django.contrib.auth.views.password_reset',
              {
                  'template_name': '?',
                  'email_template_name': '?',
                  'post_reset_redirect': 'authenticate:password_reset_done',
              },
              name='admin_password_reset',
          ),
codeblur
  • 438
  • 1
  • 3
  • 8

2 Answers2

0

The paths are:

'registration/password_reset_form.html',
'registration/password_reset_email.html'
etc.

I ended up with:

          url(
              r'^admin/password_reset/$',
              'django.contrib.auth.views.password_reset',
              {
                  'template_name': 'registration/password_reset_form.html',
                  'email_template_name': 'registration/password_reset_email.html',
                  'post_reset_redirect': 'password_reset_done',
              },
              name='admin_password_reset',
          ),
codeblur
  • 438
  • 1
  • 3
  • 8
0

You shouldn't need to do anything more than:

  • add this to your URL conf:

    url(r'^accounts/password_reset/$', 'django.contrib.auth.views.password_reset', name='admin_password_reset'),
    url(r'^accounts/', include('django.contrib.auth.urls')),`  # or use "admin" or whatever as start of path instead of "accounts")
    
  • add grappelli to INSTALLED_APPS.

No need to dig into specific template paths. This works for me anyway.

Tomas Walch
  • 2,245
  • 1
  • 14
  • 17
  • Thanks for your answer! The thing is I wanted to have the link "Forgotten your password or username?" appear beneath the login form. That appears only if admin_password_reset has been set. – codeblur Jan 28 '16 at 08:02
  • Add `url(r'^admin/password_reset', 'django.contrib.auth.views.password_reset', name='admin_password_reset'),` before the other url includes. I'll edit answer – Tomas Walch Jan 28 '16 at 08:07
  • Updated. This is tested and should work. Plus it's the simplest and smallest solution. – Tomas Walch Jan 28 '16 at 08:15