mercredi 24 juin 2015

Django rest framwork boolean field processing the checkbox 'on'

I am trying to process a checkbox in Django rest framework.

in serializers.py

is_checked = serializers.BooleanField(error_messages={'required': _('You must  check it.')})

As the rest framework doc says, HTML checkbox will pass 'on' when checked and be omitted when not checked, and the rest framework will set the value to False if the field is omitted.

So how can I show a validation error in HTML when the checkbox is not checked?




Aucun commentaire:

Enregistrer un commentaire