[Answer]-Django admin – custom fields radio – admin.HORIZONTAL not working

1πŸ‘

Take a look at this line.
So I guess it should look something like this:

from django.contrib.admin.options import get_ul_class

class BlogArticleForm(forms.ModelForm):
   image_choice = forms.ChoiceField(
                            choices=IMG_CHOICES,
                            widget=widgets.AdminRadioSelect(
                               attrs={'class': get_ul_class(admin.HORIZONTAL)}
                            ))

UPD: I’m stupid πŸ™
It says: if 'widget' not in kwargs: bla-bla-bla adds widget. So this should work with no widget:

image_choice = forms.ChoiceField(choices=IMG_CHOICES)

# And set 
radio_fields = {'image_choice': admin.HORIZONTAL}
πŸ‘€byashimov

Leave a comment