AgreementField

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

  1. Add ValidationError to a field instead of __all__ during Form.clean() by guettli 4 years, 7 months ago
  2. unique validation for ModelForm by whiskybar 5 years, 2 months ago
  3. Automatic stripping textual form fields by nail.xx 4 years, 9 months ago
  4. TRAC-Ticket on exception by identify 3 years, 10 months ago
  5. Hidden Date Display Widget for Admin by andrew.schoen 3 years, 9 months ago

Comments

chrisrbennett (on August 13, 2008):

This snippet is deprecated because the landing of newforms fixes the boolean checkbox issue.

#

(Forgotten your password?)