Django

Code

Ticket #5563 (new)

Opened 10 months ago

Last modified 7 months ago

BooleanField should raise an error if null=True

Reported by: shaunc <shaun@cuttshome.net> Assigned to: nobody
Milestone: Component: Serialization
Version: SVN Keywords:
Cc: shaun@cuttshome.net Triage Stage: Design decision needed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

django.db.models.fields.BooleanField?.to_python raises an error on "None" input, but this is valid if null=True for the field.

Attachments

booleanfield-to-python-can-be-none.patch (0.5 kB) - added by shaunc <shaun@cuttshome.net> on 09/21/07 03:02:51.
(patch to fix django.db.models.fields.init.py

Change History

09/21/07 03:02:51 changed by shaunc <shaun@cuttshome.net>

  • attachment booleanfield-to-python-can-be-none.patch added.

(patch to fix django.db.models.fields.init.py

09/21/07 03:03:18 changed by shaunc <shaun@cuttshome.net>

  • cc set to shaun@cuttshome.net.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

09/21/07 19:26:10 changed by anonymous

Isn't this what NullBooleanField? is for?

09/21/07 21:35:07 changed by shaunc <shaun@cuttshome.net>

  • has_patch deleted.
  • summary changed from BooleanField can be None if null=True to BooleanField should raise an error if null=True.

um... well, how about that: I never noticed NullBooleanField? before. I'd close this, but I'll leave it up to others to decide if the following should be done so others don't go astray:

1) doc for BooleanField? should mention that one should use NullBooleanField? rather than null=True. 2) passing null=True to BooleanField? init should cause an exception to be raised (whose error text says: "use NullBooleanField?")

09/22/07 00:02:24 changed by ubernostrum

  • stage changed from Unreviewed to Design decision needed.

There's been a lot of discussion lately about BooleanField and NullBooleanField, and it's debatable whether NullBooleanField is really appropriate for this use case.

12/17/07 15:47:42 changed by brosner

Marked #6229 as a duplicate.


Add/Change #5563 (BooleanField should raise an error if null=True)




Change Properties
Action