Django 1.10 single widget type for all ModelForm fields

140 views Asked by At

I have a ModelForm, which is composed from Model, with huge amount of columns with very different data types. However, I need to make ModelForm whose all mentioned fields in ModelForm have the same widget type (for example, checkbox, but it may be textarea, or whatever..).

ModelForm:

class EntertainerCheckboxForm(forms.ModelForm):

    class Meta:
        model = Entertainer
        fields = ['first_name', 'second_name','last_name', ...]
        widgets = {
            'first_name': CheckboxInput(),
            'second_name': CheckboxInput(),
            'last_name': CheckboxInput()
            ...
        }

Is there any simple generic solution for this?

0

There are 0 answers