[Django] #28060: Add the horizontal radio selection renderer

23 views
Skip to first unread message

Django

unread,
Apr 9, 2017, 9:20:42 AM4/9/17
to django-...@googlegroups.com
#28060: Add the horizontal radio selection renderer
-----------------------------------------+------------------------
Reporter: Musen | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
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 |
-----------------------------------------+------------------------
I propose to add the render for horizontal radio selection. When a set of
choices is rendered into a radio selection list, Django will list the
radio selection vertically by default. People come to trouble when they
want to make the radio list horizontal.

I propose to add a Horizontal radio selection render that is similar to
{{{
from django.utils.safestring import mark_safe

class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u'\n'.join([u'%s\n' % w for w in self]))


class ApprovalForm(forms.Form):
approval = forms.ChoiceField(choices=APPROVAL_CHOICES,
initial=0,
widget=forms.RadioSelect(renderer=HorizontalRadioRenderer),
)
}}}

This could as solve ticket #28059.

PS. The code for `HorizontalRadioRenderer` seems to be a folklore on the
internet for years, it can be found on
*[http://stackoverflow.com/questions/5935546/align-radio-buttons-
horizontally-in-django-forms stackoverflow] and
*[https://wikis.utexas.edu/display/~bm6432/Django-
Modifying+RadioSelect+Widget+to+have+horizontal+buttons UTexas Wiki].

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

Django

unread,
Apr 9, 2017, 9:21:06 AM4/9/17
to django-...@googlegroups.com
#28060: Add the horizontal radio selection renderer
-------------------------------+--------------------------------------
Reporter: Musen | Owner: Musen
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: 1.11
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/28060#comment:1>

Django

unread,
Apr 9, 2017, 9:22:23 AM4/9/17
to django-...@googlegroups.com
#28060: Add the horizontal radio selection renderer
-----------------------------+--------------------------------------
Reporter: Musen | Owner: Musen
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

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

* needs_docs: 0 => 1
* version: 1.11 => master
* component: Uncategorized => Forms
* needs_tests: 0 => 1
* type: Uncategorized => New feature


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

Django

unread,
Apr 9, 2017, 2:07:35 PM4/9/17
to django-...@googlegroups.com
#28060: Add the horizontal radio selection renderer
-----------------------------+--------------------------------------
Reporter: Musen | Owner: Musen
Type: New feature | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by Simon Charette):

Isn't this something that can be achieved by styling the list elements to
be displayed horizontally instead?

Just wanted to say I don't think that stripping all the markup is the way
to go here.

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

Django

unread,
Apr 11, 2017, 10:03:15 AM4/11/17
to django-...@googlegroups.com
#28060: Add the horizontal radio selection renderer
-----------------------------+--------------------------------------
Reporter: Musen | Owner: Musen
Type: New feature | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Tim Graham):

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


Comment:

I think #28059 will be fixed by restoring the CSS classes on the `<ul>`
that were there before 1.11. Presumably the same solution could be used in
other apps. The code in the ticket description no longer words after the
introduction of template-based widget rendering in Django 1.11.

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

Reply all
Reply to author
Forward
0 new messages