[Django] #23993: Default admin login.html form doesn't respect custom AuthenticationForm Media assets.

28 views
Skip to first unread message

Django

unread,
Dec 14, 2014, 11:55:16 AM12/14/14
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------+--------------------
Reporter: Sveder | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/23993>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 15, 2014, 9:25:51 PM12/15/14
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------+--------------------------------------

Reporter: Sveder | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by berkerpeksag):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

How did you replace the admin authentication form? If you replace it by
overriding `AdminSite.login_form`, you can also override the
`AdminSite.login_template` attribute and set your custom login template
path.

--
Ticket URL: <https://code.djangoproject.com/ticket/23993#comment:1>

Django

unread,
Dec 19, 2014, 9:11:24 AM12/19/14
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------+------------------------------------

Reporter: Sveder | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


Comment:

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).

--
Ticket URL: <https://code.djangoproject.com/ticket/23993#comment:2>

Django

unread,
Dec 19, 2014, 10:06:02 AM12/19/14
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------+------------------------------------

Reporter: Sveder | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Sveder):

Replying to [comment:2 timgraham]:


> 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).

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/23993#comment:3>

Django

unread,
Dec 19, 2014, 10:08:40 AM12/19/14
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------+------------------------------------

Reporter: Sveder | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Sveder):

Replying to [comment:1 berkerpeksag]:


> How did you replace the admin authentication form? If you replace it by
overriding `AdminSite.login_form`, you can also override the
`AdminSite.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.

--
Ticket URL: <https://code.djangoproject.com/ticket/23993#comment:4>

Django

unread,
Jan 13, 2015, 9:54:10 PM1/13/15
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------+------------------------------------

Reporter: Sveder | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by arcturusannamalai):

@Sveder - I guess you should assign this ticket to yourself, since the
solution is part of the problem description. Good work :-)

--
Ticket URL: <https://code.djangoproject.com/ticket/23993#comment:5>

Django

unread,
Mar 7, 2015, 4:56:04 AM3/7/15
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------+------------------------------------
Reporter: Sveder | Owner: dakrauth
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by dakrauth):

* owner: nobody => dakrauth
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/23993#comment:6>

Django

unread,
Mar 7, 2015, 6:01:40 AM3/7/15
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------+------------------------------------
Reporter: Sveder | Owner: dakrauth
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by dakrauth):

* has_patch: 0 => 1


Comment:

Pull request https://github.com/django/django/pull/4257

--
Ticket URL: <https://code.djangoproject.com/ticket/23993#comment:7>

Django

unread,
Mar 7, 2015, 6:52:32 AM3/7/15
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------------+-------------------------------------

Reporter: Sveder | Owner: dakrauth
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by tino):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/23993#comment:8>

Django

unread,
Mar 7, 2015, 7:02:31 AM3/7/15
to django-...@googlegroups.com
#23993: Default admin login.html form doesn't respect custom AuthenticationForm
Media assets.
-------------------------------------+-------------------------------------
Reporter: Sveder | Owner: dakrauth
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Erik Romijn <eromijn@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"88c605e3e34cebd5485d286a17ac84c7b8b0faf1"]:
{{{
#!CommitTicketReference repository=""
revision="88c605e3e34cebd5485d286a17ac84c7b8b0faf1"
Fixed #23993 -- Added form.media to the admin login template.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23993#comment:9>

Reply all
Reply to author
Forward
0 new messages