Pregunta

I'm using Django 1.6 and django-registration 1.0

I had to explicitly specify the reset URL

url(r'^password/reset/done/$', password_reset_done, name='password_reset_done'),

But it keeps pulling in the admin templates.

Why would that happen? How can I override this to custom templates?

UPDATE: Tried the following and it still pulls in the admin templates...

url(r'^password/reset/', password_reset,
        {'template_name': 'registration/password_reset_form.html'}, name='password_reset'),
url(r'^accounts/password/reset/done/$', password_reset_done,
        {'template_name': 'registration/password_reset_done.html'}, name='password_reset_done'),

No hay solución correcta

Otros consejos

I believe password_reset_done is a method of one of django's builtin apps. You can read more about this auth app on the official doc here.

Django's url dispatcher allows to pass extra options to a view function. Luckily, password_reset_done function accepts optional parameters like template_name, current_app or extra_context.

Putting these together, you can do the following:

url(r'^password/reset/done/$', password_reset_done, {'template_name': PATH_TO_YOUR_CUSTOM_TEMPLATE}, name='password_reset_done'),

To learn more about the url function, please read this API doc.

The order of the list of apps in INSTALLED_APPS (in settings.py) is the order Django will use to find templates. If two templates share the same name, then the app which is listed first will win. This means that in INSTALLED_APPS, you need to make sure that the 'django.contrib.admin' app is after whichever app contains the template files you wish to use instead (presumably, the 'registration' app). Like this:

# settings.py
...
INSTALLED_APPS = (
    ...
    'registration', # Or whichever app contains the template you want to use
    'django.contrib.admin',
    ...
)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top