Skip to content

Instantly share code, notes, and snippets.

@artofhuman
Created October 3, 2012 11:24
Show Gist options
  • Save artofhuman/3826463 to your computer and use it in GitHub Desktop.
Save artofhuman/3826463 to your computer and use it in GitHub Desktop.
Django HorizRadioSelect
from django.utils.html import mark_safe
from django.forms.widgets import RadioSelect
class HorizRadioRenderer(RadioSelect.renderer):
""" this overrides widget method to put radio buttons horizontally
instead of vertically.
"""
def render(self):
"""Outputs radios"""
return mark_safe(u'\n'.join([u'%s\n' % w for w in self]))
class HorizRadioSelect(RadioSelect):
renderer = HorizRadioRenderer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment