[Answer]-Change default form widget for choices

1👍

Create a ModelForm that specifies the behaviors as a checkbox:

from django.forms import ModelForm, CheckboxInput

class SurveyForm(ModelForm):
    behaviors =  forms.ChoiceField(choices=OPTIONS, widget=CheckboxInput)

Now you can use this form in your Admin or CBVs to render the behaviors as a checkbox.

Take also a look here: https://docs.djangoproject.com/en/dev/ref/forms/fields/#widget

Leave a comment