I've constructed this form from a model.
class Configure_template(forms.Form):
subject_type = forms.ChoiceField(choices=Subject_type.objects.all())
And I want to render this using radio buttons but I have problems with the for in the html,
Thanks for any suggestion.
Use a RadioSelect
widget on your form field:
subject_type = forms.ChoiceField(choices=Subject_type.objects.all(),
widget=forms.RadioSelect)
If you want to show radiobuttons with choices from database use cannot use ChoiceField.
You have to use a ModelChoiceField.
subject_type = forms.ModelChoiceField(widget=forms.RadioSelect, queryset=Subject_type.objects.all(), label='')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With