class ButtonRadioSelect(forms.RadioSelect): """Radio Select with overridden renderer, placing labels after inputs. To make 3d stateful buttons, add CSS:: """ class ButtonRadioInput(forms.widgets.RadioInput): def __unicode__(self): # No idea, why Superclass' __unicode__ does not call # correct render() method return self.render() def render(self, name=None, value=None, attrs=None, choices=()): name = name or self.name value = value or self.value attrs = attrs or self.attrs if 'id' in self.attrs: label_for = ' for="%s_%s"' % (self.attrs['id'], self.index) else: label_for = '' choice_label = conditional_escape(force_unicode(self.choice_label)) return mark_safe(u'%s ' % (self.tag(), label_for, choice_label)) class ButtonRadioFieldRenderer(forms.widgets.RadioFieldRenderer): def __iter__(self): for i, choice in enumerate(self.choices): yield ButtonRadioSelect.ButtonRadioInput(self.name, self.value, self.attrs.copy(), choice, i) def __getitem__(self, idx): choice = self.choices[idx] # Let the IndexError propogate return ButtonRadioSelect.ButtonRadioInput(self.name, self.value, self.attrs.copy(), choice, idx) def render(self): """Outputs a