Opened 10 years ago
Closed 10 years ago
#23993 closed Bug (fixed)
Default admin login.html form doesn't respect custom AuthenticationForm Media assets.
Reported by: | Sveder | Owned by: | David A Krauth |
---|---|---|---|
Component: | contrib.admin | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
If you replace the admin AuthenticationForm with a custom one and add form assets as described in https://docs.djangoproject.com/en/1.7/topics/forms/media/ (using the media class), it won't be reflected in the application. The root cause is that the admin/login.html template doesn't have the line {{form.media}} anywhere.
Adding that line fixes this.
Change History (9)
follow-up: 4 comment:1 by , 10 years ago
follow-up: 3 comment:2 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
I think it's reasonable if {{ form.media }}
is included in the template by default (although there is a possibility the Media
class will be deprecated at some point in favor of some other hook, see #22298).
comment:3 by , 10 years ago
Replying to timgraham:
I think it's reasonable if
{{ form.media }}
is included in the template by default (although there is a possibility theMedia
class will be deprecated at some point in favor of some other hook, see #22298).
Thanks for the reply. It is such a small fix that it is worth doing even though Media might be deprecated. I'll submit a patch before the weekend is over.
comment:4 by , 10 years ago
Replying to berkerpeksag:
How did you replace the admin authentication form? If you replace it by overriding
AdminSite.login_form
, you can also override theAdminSite.login_template
attribute and set your custom login template path.
That is indeed the workaround but it's not a good solution as you need to keep updating your new "custom" login html with whatever changes happen in Django. I think the idiomatic way to do it (for now) is using Media, and it should work as expected. Thank you for noting the workaround though, in case other people stumble over this.
comment:5 by , 10 years ago
@Sveder - I guess you should assign this ticket to yourself, since the solution is part of the problem description. Good work :-)
comment:6 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:8 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:9 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
How did you replace the admin authentication form? If you replace it by overriding
AdminSite.login_form
, you can also override theAdminSite.login_template
attribute and set your custom login template path.