Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#20186 closed Bug (invalid)

Overriding registration/logged_out.html template doesn't work

Reported by: honyczek Owned by: nobody
Component: contrib.auth Version: 1.5
Severity: Normal Keywords: templates, auth, login, logout
Cc: bmispelon@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes


After updating to Django 1.5 (from 1.4) there is default template displayed for logged out users.

It used to be overriden by including registration/logged_out.html into some application templates directory. But now it doesn't work. Only registration/login.html works.

Change History (8)

comment:1 Changed 5 years ago by Baptiste Mispelon

Cc: bmispelon@… added
Resolution: needsinfo
Status: newclosed


The registration/logged_out.html template was already there in 1.4 (provided by django.contrib.admin).

I've made some quick tests and I can't reproduce the issue you're describing.

Could you provide a test case for it or maybe just a list of steps to follow to reproduce the problem?


comment:2 Changed 5 years ago by honyczek


some years ago i started my project and followed Django tutorial. Once I wanted to customize my login and logout pages, so I read and copied admin templates login.html and logged_out.html to <project_directory>/templates/registration/. It worked until Django 1.5. Now the logged_out.html doesn't work. Maybe template path changed...

So now I've opened Admin docs and there is described another way to override login and logout templates. So if the tutorial way is incorrect, it should be updated.

comment:3 Changed 5 years ago by Hervé Cauwelier

Just got hit by that bug in Django 1.5.1.

I have overridden "registration/login.html" without even thinking about it, but then I wanted to override all of the other "registration/*.html" templates.

But only "login.html" will come from my app (the last one in INSTALLED_APPS). All of the other ones are still the admin templates.

I'll try and set up a minimal projet to reproduce the issue.

comment:4 Changed 5 years ago by Hervé Cauwelier

Resolution: needsinfo
Status: closednew

comment:5 Changed 5 years ago by Hervé Cauwelier


You'll find at a minimal project (fresh out of startproject/startapp) that reproduces the bug.

"registration/login.html" is mine but "registration/logged_out.html" still is the admin template.

comment:6 Changed 5 years ago by Baptiste Mispelon

Resolution: invalid
Status: newclosed

Thanks herve for taking the time to write a test project.

I think there is a misunderstanding here, not a bug. Let me try and explain.

The login and logout views from dango.contrib.auth use registration/login.html and registration/logged_out.html respectively.

In addition to that, django.contrib.admin provides a registration/logged_out.html, but no registration/login.html (it uses its own admin/login.html).

If django.contrib.admin appears before your own app in settings.INSTALLED_APPS, then the logout view will use the admin's template instead of your app's.
This has not changed recently, as you can check by running herve's test project under different versions of django.

As for the tutorial being incorrect, I disagree.
If you read the link given by honyczek in his/her comment, you'll see that it recommends putting the templates inside a directory specified in setings.TEMPLATE_DIRS.
You can check previous versions of django and see that this is not a new addition (in fact it's been this way since django 1.0).

With the default settings, TEMPLATE_DIRS will take precedence over any app-specific templates so any templates you provide in thos directory will be used over the ones defined by contrib.admin.

I'm closing this ticket as invalid since the behavior described appears not to be a bug (and furthermore, there is no change between 1.4 and 1.5).

comment:7 Changed 5 years ago by Hervé Cauwelier

Thanks for the explanation, I just assumed the apps were browsed for templates from last to first.

In the mean time, I found that template directories defined in settings.TEMPLATE_DIRS have precedence over any app template directory. So I'll just move my "registration/*" templates here.

comment:8 in reply to:  7 Changed 5 years ago by Simon Charette

Replying to herve:

In the mean time, I found that template directories defined in settings.TEMPLATE_DIRS have precedence over any app template directory. So I'll just move my "registration/*" templates here.

Just to clarify, the precedence is determined by the order of your TEMPLATE_LOADERS setting. I guess 'django.template.loaders.filesystem.Loader' appears before before 'django.template.loaders.app_directories.Loader' in your settings.

Note: See TracTickets for help on using tickets.
Back to Top