Opened 16 years ago

Closed 16 years ago

#8676 closed (wontfix)

BooleanField says value required if False

Reported by: Bernd Dorn Owned by: nobody
Component: Uncategorized Version: dev
Severity: Keywords: forms
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The BooleanField should accept False values and not raise the required error. Here is a diff from the http://code.djangoproject.com/svn/django/tags/notable_moments/1.0-beta-1 branch. The problem is in trunk too.

Index: django/forms/fields.py
===================================================================
--- django/forms/fields.py	(revision 8696)
+++ django/forms/fields.py	(working copy)
@@ -569,9 +569,9 @@
         if value == 'False':
             value = False
         else:
-            value = bool(value)
+            value = value and True or None
         super(BooleanField, self).clean(value)
-        if not value and self.required:
+        if value is None and self.required:
             raise ValidationError(self.error_messages['required'])
         return value
 

Change History (1)

comment:1 by Daniel Pope <dan@…>, 16 years ago

Resolution: wontfix
Status: newclosed

The opposite behaviour was decided in #5957.

Note: See TracTickets for help on using tickets.
Back to Top