开发者

Why is my registration/reset_password_done.html template not used by Django?

I have an urls.py:

from django.contrib.auth.views import (password_reset, password_reset_done, 
                                       password_change, password_change_done)

 [...]
 urlpatterns += i18n_patterns('',   
        url(r'^accounts/password_reset/$', password_reset, 
             {'template_name': 'registration/password_reset.html',
              "post_reset_redirect": '/accounts/password_reset_done/' },
             name='reset-password'),
        url(r'^accounts/password_reset_done/$', password_reset_done, 
             {'template_name': 'registration/password_reset_done.html'},
             name="reset-password-done"))

And the associated templates in app/templates/registration.

The password_reset do display my template, but password_reset_done doesn't (it shows the admin template with the sa开发者_如何学Gome name). Running pdb in it confirms that the proper template name is passed. I tripple checked the name of the template.


I finally found the answer:

The app template loader will render the first template he finds matching the name, this order is determined by the order of your app in INSTALLED_APPS.

Just adding the name of my app which contains my template at the begining of INSTALLED_APPS solve the problem.


What about changing the name of your password_reset_done.html to, say, password_reset_done2.html and changing urls.py accordingly? Is there still a conflict between this and the admin template?

Also, it could have to do with where the urlpatterns += i18n_patterns... code occurs. Does it occur before or after the default admin urls:

(r'^admin/', include(<location of default admin urls>)),

.. or whatever it looks like. Maybe they override your custom urls?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜