[Answer]-Django model choice field does not render as radio button

1👍

I think there was a problem in my css and using django widget tweaks. I removed adding css from django widget tweaks and added it to the form and it worked.

Like this:

state = forms.ChoiceField(choices=STATE_TYPES, widget=forms.RadioSelect(attrs={'class':'radio_1', 'name': 'name2'}))
👤Atma

0👍

You’re supposed to just output the field, not iterate through its attributes. Just:

{{ form.state }}

Leave a comment