Opened 11 years ago

Closed 11 years ago

#20723 closed Cleanup/optimization (needsinfo)

model_to_dict requires True, False, or '' instead of 0, 1, or '' when NullBooleanField

Reported by: helen.mayhew@… Owned by: nobody
Component: Documentation Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a model with

addr_to_photographer = models.NullBooleanField(blank=True, null=True)

and I have a custom save function in my model that uses model_to_dict.
Previously, the field was a regular models.BooleanField(), and in the json for my POST, I had to send 0, 1, or nothing to fill the value. Once I changed the field to be models.NullBooleanField, 0, 1, and nothing ALL stored as null. I had to change my POST json to send True, False, or nothing to get it to work. I just think it would be helpful to note this in the documentation about model_to_dict and/or NullBoolean. Thanks.

Change History (2)

comment:1 by Tim Graham, 11 years ago

model_to_dict doesn't appear to be documented. I sort of understand your issue, but it seems like it may be fairly specific to your app and I'm not quite sure what documentation to add. Could you propose some text or a patch?

comment:2 by Tim Graham, 11 years ago

Resolution: needsinfo
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top