Ticket #1767: boolean_validator_list.diff

File boolean_validator_list.diff, 1.6 KB (added by jkocherhans, 19 years ago)

allows validator_list for boolean fields

  • django/db/models/fields/__init__.py

     
    252252        params['is_required'] = not self.blank and not self.primary_key and not rel
    253253
    254254        # BooleanFields (CheckboxFields) are a special case. They don't take
    255         # is_required or validator_list.
     255        # is_required.
    256256        if isinstance(self, BooleanField):
    257             del params['validator_list'], params['is_required']
     257            del params['is_required']
    258258
    259259        # If this field is in a related context, check whether any other fields
    260260        # in the related object have core=True. If so, add a validator --
  • django/forms/__init__.py

     
    431431            (self.get_id(), self.field_name, escape(data))
    432432
    433433class CheckboxField(FormField):
    434     def __init__(self, field_name, checked_by_default=False):
     434    def __init__(self, field_name, checked_by_default=False, validator_list=[]):
    435435        self.field_name = field_name
    436436        self.checked_by_default = checked_by_default
    437         self.is_required, self.validator_list = False, [] # because the validator looks for these
     437        self.is_required = False # because the validator looks for this
     438        self.validator_list = validator_list[:]
    438439
    439440    def render(self, data):
    440441        checked_html = ''
Back to Top