[Django] #28059: Admin page cannot render horizontal radio buttons

7 views
Skip to first unread message

Django

unread,
Apr 9, 2017, 1:59:01 AM4/9/17
to django-...@googlegroups.com
#28059: Admin page cannot render horizontal radio buttons
-----------------------------------------+------------------------
Reporter: Musen | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
To reproduce the bug, suppose we have the model `Person` defined in
`models.py`

{{{
class Person(Models.model):
age = CharField(choices = (('Y', 'Young'), ('O', 'Old')))
}}}
We want to display the choice of age in our admin change page in radio
buttons, so we have the following codes in `admin.py`
{{{
from .models import Person

class PersonAdmin(admin.ModelAdmin):
radio_fields = {'age': admin.HORIZONTAL}

admin.site.register(Person, PersonAdmin)
}}}

Then, we will get the vertical radio buttons instead of the horizontal
ones.

The bug is caused by the wrong HTML attribute that the `ModelAdmin` uses
to produce horizontal radio buttons. The correct attribute is `radio-
inline` but `ModelAdmin` uses `radiolist inline`. Also, since HTML uses
the vertical radio buttons as default, function `get_ul_class` is useless,
and it can be simply replaced by an if statement.

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

Django

unread,
Apr 9, 2017, 1:59:28 AM4/9/17
to django-...@googlegroups.com
#28059: Admin page cannot render horizontal radio buttons
-------------------------------+--------------------------------------
Reporter: Musen | Owner: Musen
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Musen):

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


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

Django

unread,
Apr 9, 2017, 5:42:35 AM4/9/17
to django-...@googlegroups.com
#28059: Admin page cannot render horizontal radio buttons
-------------------------------+--------------------------------------
Reporter: Musen | Owner: Musen
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by Musen:

Old description:

> To reproduce the bug, suppose we have the model `Person` defined in
> `models.py`
>
> {{{
> class Person(Models.model):
> age = CharField(choices = (('Y', 'Young'), ('O', 'Old')))
> }}}
> We want to display the choice of age in our admin change page in radio
> buttons, so we have the following codes in `admin.py`
> {{{
> from .models import Person
>
> class PersonAdmin(admin.ModelAdmin):
> radio_fields = {'age': admin.HORIZONTAL}
>
> admin.site.register(Person, PersonAdmin)
> }}}
>
> Then, we will get the vertical radio buttons instead of the horizontal
> ones.
>
> The bug is caused by the wrong HTML attribute that the `ModelAdmin` uses
> to produce horizontal radio buttons. The correct attribute is `radio-
> inline` but `ModelAdmin` uses `radiolist inline`. Also, since HTML uses
> the vertical radio buttons as default, function `get_ul_class` is
> useless, and it can be simply replaced by an if statement.

New description:

To reproduce the bug, suppose we have the model `Person` defined in
`models.py`

{{{
class Person(Models.model):
age = CharField(choices = (('Y', 'Young'), ('O', 'Old')))
}}}
We want to display the choice of age in our admin change page in radio
buttons, so we have the following codes in `admin.py`
{{{
from .models import Person

class PersonAdmin(admin.ModelAdmin):
radio_fields = {'age': admin.HORIZONTAL}

admin.site.register(Person, PersonAdmin)
}}}

Then, we will get the vertical radio buttons instead of the horizontal
ones.

--

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

Django

unread,
Apr 11, 2017, 9:30:16 AM4/11/17
to django-...@googlegroups.com
#28059: ModelAdmin.radio_fields doesn't render admin.HORIZONTAL CSS classes
---------------------------------+------------------------------------

Reporter: Musen | Owner: Musen
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.11
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted
* version: master => 1.11
* severity: Normal => Release blocker


Old description:

> To reproduce the bug, suppose we have the model `Person` defined in
> `models.py`
>
> {{{
> class Person(Models.model):
> age = CharField(choices = (('Y', 'Young'), ('O', 'Old')))
> }}}
> We want to display the choice of age in our admin change page in radio
> buttons, so we have the following codes in `admin.py`
> {{{
> from .models import Person
>
> class PersonAdmin(admin.ModelAdmin):
> radio_fields = {'age': admin.HORIZONTAL}
>
> admin.site.register(Person, PersonAdmin)
> }}}
>
> Then, we will get the vertical radio buttons instead of the horizontal
> ones.

New description:

To reproduce the bug, suppose we have the model `Person` defined in
`models.py`

{{{
class Person(models.Model):
age = models.CharField(max_length=1, choices=(('Y', 'Young'), ('O',


'Old')))
}}}
We want to display the choice of age in our admin change page in radio
buttons, so we have the following codes in `admin.py`
{{{
from .models import Person

class PersonAdmin(admin.ModelAdmin):
radio_fields = {'age': admin.HORIZONTAL}

admin.site.register(Person, PersonAdmin)
}}}

Then, we will get the vertical radio buttons instead of the horizontal
ones.

--

Comment:

It's a regression in 1.11 caused by template-based widget rendering.

In older versions, the generated HTML looks like: `<ul class="radiolist
inline" id="id_age">` but the classes are now missing as the
[https://github.com/django/django/blob/5dbf1c4b23cda915369f4895be293369575238d0/django/forms/templates/django/forms/widgets/multiple_input.html
multiple_input.html] template doesn't consider them.

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

Django

unread,
Apr 15, 2017, 2:00:47 PM4/15/17
to django-...@googlegroups.com
#28059: ModelAdmin.radio_fields doesn't render admin.HORIZONTAL CSS classes
---------------------------------+------------------------------------
Reporter: Musen | Owner: Musen
Type: Bug | Status: assigned
Component: contrib.admin | Version: 1.11
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8363 PR]

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

Django

unread,
Apr 20, 2017, 11:08:07 AM4/20/17
to django-...@googlegroups.com
#28059: ModelAdmin.radio_fields doesn't render admin.HORIZONTAL CSS classes
---------------------------------+------------------------------------
Reporter: Musen | Owner: Musen
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.11
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"af1f986360dc6bb6e75e960dbc191707541128ac" af1f9863]:
{{{
#!CommitTicketReference repository=""
revision="af1f986360dc6bb6e75e960dbc191707541128ac"
Fixed #28059 -- Restored class attribute in <ul> of widgets that use
multiple_input.html.

Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01
}}}

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

Django

unread,
Apr 20, 2017, 11:14:41 AM4/20/17
to django-...@googlegroups.com
#28059: ModelAdmin.radio_fields doesn't render admin.HORIZONTAL CSS classes
---------------------------------+------------------------------------
Reporter: Musen | Owner: Musen
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.11
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"2f358d32ec4197d3fd7c246272ed2719d674c8d7" 2f358d32]:
{{{
#!CommitTicketReference repository=""
revision="2f358d32ec4197d3fd7c246272ed2719d674c8d7"
[1.11.x] Fixed #28059 -- Restored class attribute in <ul> of widgets that
use multiple_input.html.

Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01

Backport of af1f986360dc6bb6e75e960dbc191707541128ac from master
}}}

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

Reply all
Reply to author
Forward
0 new messages