Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1767 -- boolean fields may now have validators! Thanks, Joseph.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3467 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a55fa029f765fb824d6227a4d3bf6e7fbcd1c260 1 parent 09912cc
Jacob Kaplan-Moss authored July 28, 2006
4  django/db/models/fields/__init__.py
@@ -247,9 +247,9 @@ def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=
247 247
         params['is_required'] = not self.blank and not self.primary_key and not rel
248 248
 
249 249
         # BooleanFields (CheckboxFields) are a special case. They don't take
250  
-        # is_required or validator_list.
  250
+        # is_required.
251 251
         if isinstance(self, BooleanField):
252  
-            del params['validator_list'], params['is_required']
  252
+            del params['is_required']
253 253
 
254 254
         # If this field is in a related context, check whether any other fields
255 255
         # in the related object have core=True. If so, add a validator --
6  django/forms/__init__.py
@@ -434,10 +434,12 @@ def render(self, data):
434 434
             (self.get_id(), self.field_name, escape(data))
435 435
 
436 436
 class CheckboxField(FormField):
437  
-    def __init__(self, field_name, checked_by_default=False):
  437
+    def __init__(self, field_name, checked_by_default=False, validator_list=None):
  438
+        if validator_list is None: validator_list = []
438 439
         self.field_name = field_name
439 440
         self.checked_by_default = checked_by_default
440  
-        self.is_required, self.validator_list = False, [] # because the validator looks for these
  441
+        self.is_required = False # because the validator looks for these
  442
+        self.validator_list = validator_list[:]
441 443
 
442 444
     def render(self, data):
443 445
         checked_html = ''

0 notes on commit a55fa02

Please sign in to comment.
Something went wrong with that request. Please try again.