HI
I want to align the radio buttons horizontally. By default django forms displays in vertical format.
feature_type = forms.TypedChoiceField(choices =
There is actually no need to override the widget, template or anything else in admin. At least since 2008 (see forms.css), the easiest way is to pass a class attribute inline
: attrs={'class': 'inline'}
In a custom form, it may look like:
field = forms.ChoiceField(choices=(('1', 'one'), ('2', 'two')),
widget=forms.RadioSelect(attrs={'class': 'inline'}))
… and it works the very same for checkboxes:
field = forms.MultipleChoiceField(choices=(('1', 'one'), ('2', 'two')),
widget=forms.CheckboxSelectMultiple(attrs={'class': 'inline'}))
And it should be the very same for formfield overrides, either via ModelAdmin formfield_overrides
or formfield_for_*
functions.