Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#28059 closed Bug (fixed)

ModelAdmin.radio_fields doesn't render admin.HORIZONTAL CSS classes

Reported by: Musen Owned by: Musen
Component: contrib.admin Version: 1.11
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

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.

Change History (6)

comment:1 by Musen, 8 years ago

Owner: changed from nobody to Musen
Status: newassigned

comment:2 by Musen, 8 years ago

Description: modified (diff)

comment:3 by Tim Graham, 8 years ago

Description: modified (diff)
Severity: NormalRelease blocker
Summary: Admin page cannot render horizontal radio buttonsModelAdmin.radio_fields doesn't render admin.HORIZONTAL CSS classes
Triage Stage: UnreviewedAccepted
Version: master1.11

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 multiple_input.html template doesn't consider them.

comment:4 by Tim Graham, 8 years ago

Has patch: set

comment:5 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In af1f9863:

Fixed #28059 -- Restored class attribute in <ul> of widgets that use multiple_input.html.

Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01

comment:6 by Tim Graham <timograham@…>, 8 years ago

In 2f358d32:

[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

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