0

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

1 Answer 1

1
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']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.