Reputation:
I want to add bootstrap style to my radio buttons however I do not know how to do this.
This is my form:
class GenderForm(forms.ModelForm):
CHOICES=[('Male','0'),('Female','1')]
Gender = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect())
class Meta:
model = Data
fields = ['Gender']
I am calling the form as follows:
<form action="{% url 'gender'%}" method="POST">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Gender</legend>
{{ Gen_form|crispy}}
</fieldset>
<div class="form-group">
<button class="btn btn-outline-info" type="submit">Confirm</button>
</div>
-->
Thank you for any help in advance
Upvotes: 0
Views: 152
Reputation: 1466
class GenderForm(forms.ModelForm):
CHOICES=[('Male','0'),('Female','1')]
Gender = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect(attrs={
'class': 'CSS CLASS THAT YOU NEED FOR IT',
}))
class Meta:
model = Data
fields = ['Gender']
Upvotes: 1