1 2 3 4 5 6 7 8 9 | from django.newforms.fields import BooleanField
from django.newforms import ValidationError
class AgreementField(BooleanField):
def clean(self, value):
super(AgreementField, self).clean(value)
if not value:
raise ValidationError("You must agree to continue.")
else:
return value
|
More like this
- unique validation for ModelForm by whiskybar 3 years, 10 months ago
- CheckedField by oggy 3 years, 4 months ago
- Add ValidationError to a field instead of __all__ during Form.clean() by guettli 3 years, 3 months ago
- CheckBoxField and MultipleCheckBoxField by sergiohinojosa 3 years, 2 months ago
- Hidden Date Display Widget for Admin by andrew.schoen 2 years, 6 months ago
Comments
This snippet is deprecated because the landing of newforms fixes the boolean checkbox issue.
#