Opened 7 years ago

Closed 7 years ago

#8676 closed (wontfix)

BooleanField says value required if False

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

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 Changed 7 years ago by Daniel Pope <dan@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

The opposite behaviour was decided in #5957.

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