I am learning Django and I want to use the form-check Bootstrap class for a checkbox but it isn't working correctly.
This is the code of my file vaccines_form.html
:
{{ form.vacuna }}
This code of my file forms.py
works fine:
widgets = {
'vacuna': forms.CheckboxSelectMultiple(),
}
But this doesn't work well:
widgets = {
'vacuna': forms.CheckboxSelectMultiple(attrs={'class': 'form-check'}),
}
I am using Django 3.2.2 with Bootstrap v5.0.0 but I am not sure if Bootstrap 5 is compatible with Django 3.2.2. Maybe I don't have to use Bootstrap classes in forms.py
and use only in vaccines_form.html
.
save time and try django crispy forms