如何将引导添加到Django表单,py?

如何将引导添加到Django表单,py?,django,Django,我想添加引导风格到我的单选按钮,但我不知道如何做到这一点 这是我的表格: class GenderForm(forms.ModelForm): CHOICES=[('Male','0'),('Female','1')] Gender = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect()) class Meta: model = Data fields = ['Gender'] 我按如下方式填写表格: &

我想添加引导风格到我的单选按钮,但我不知道如何做到这一点

这是我的表格:

class GenderForm(forms.ModelForm):
CHOICES=[('Male','0'),('Female','1')]
Gender = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect())

class Meta:
    model = Data
    fields = ['Gender']
我按如下方式填写表格:

<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>

{%csrf_令牌%}
性别
{{Gen_form | crispy}}
证实
--> 谢谢你事先的帮助

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']