#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.577945975792d0273526e034ac85d72b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to