Search code examples
djangoformsdjango-formsmodelformmultiple-choice

DJANGO: Change field size of ModelMultipleChoiceField?


I was wondering how one changes the size of a ModelMultipleChoiceField? I've only seen examples of changing a CharField into a Textarea... Is this possible?

Models.PY

class FilterForm(forms.Form):
    Person = forms.ModelMultipleChoiceField(required=False, queryset=Person.objects.all(), attrs={'cols': 50, 'rows': 10})

Solution

  • You can change the width and height of the widget by applying CSS to the <select> element that Django creates.