[Fixed]-CheckBox Input Validation in Django

23👍

Don’t use a ChoiceField for a single checkbox. Use a BooleanField.

terms = forms.BooleanField(
    error_messages={'required': 'You must accept the terms and conditions'},
    label="Terms&Conditions"
)

You don’t even need a clean_ method.

Leave a comment