[Django]-Django Forms Validation Check is not working

2👍

This is already the case, since you did not specify blank=True [Django-doc], this means that the form field is required, so this means that for the form field, required=True [Django-doc], and for a BooleanField form field [Django-doc], this means:

Since all Field subclasses have required=True by default, the validation condition here is important. If you want to include a boolean in your form that can be either True or False (e.g. a checked or unchecked checkbox), you must remember to pass in required=False when creating the BooleanField.

You thus can simply let Django do the work:

class CheckForm(forms.ModelForm):
    translated_names = TranslationField()

    # no clean override

    class Meta:
        model = models.Check
        fields = '__all__'

Leave a comment