Confused by behavior of Django 1.5 with auth password change on the template name location -
i new django, , confused behavior , scratching head understand why it's not working way expect.
i customizing template password change (password_change_form.html) , put in application template directory under registration.
i using django-registration. in settings.py in installed_apps have default apps in default order ('django.contrib.auth' etc...), app, , registration. admin enabled. know django looks templates in order set in installed_apps variable.
in project urls.py have
urlpatterns = patterns('', url(r'', include('website.urls', namespace="website")), url(r'^admin/', include(admin.site.urls)), (r'^accounts/', include('registration.backends.default.urls')), ) urlpatterns += staticfiles_urlpatterns() in application urls.py have
urlpatterns = patterns('', url(r'^$', views.home, name='home'), url(r'^accounts/profile/password/change/$', 'django.contrib.auth.views.password_change', {'template_name': 'registration/password_change_form.html'}, name='edit_password'), ) my confusion if leave template_name set 'registration/password_change_form.html' django display default admin form password change not custom template.
i created directory under app templates called auth , copied template @ location. if change template_name 'auth/password_change_form.html' django show template!
i confused because django not following my instruction use template @ location registration if it's @ location auth.
can explain me what's happening under hood of django 1.5 , why use template if it's in directory likes?!
yeah, problem first instruction default instruction - same 1 pulls password_change_form.html in installed app order. if examine default value template_name field, setting to. because set value instead of letting take default value - still processes same way. looks in order of installed_apps template directory registration subdirectory, , password_change_form.html file. regardless, unless give name does not exist in default django auth templates - won't go want (unless place app before auth app in settings). now, if want keep folder structure same, change name of file , pass in correct name template_name field.
Comments
Post a Comment