Opened 3 years ago
Closed 3 years ago
#33289 closed Bug (invalid)
JSONField Form Field doesn't accept valid JSON boolean or null
Reported by: | David Anderson | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 3.1 |
Severity: | Normal | Keywords: | jsonfield json null boolean |
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'm running into an issue with POSTing data to a django form using JSONField on postgres when the contents being posted includes true
, false
, or null
.
It looks like others have run into this here and here:
- https://stackoverflow.com/questions/53450315/posting-json-boolean-django
- https://stackoverflow.com/questions/68105703/problem-with-django-serializer-involving-nested-json-with-null-and-boolean-value, I think.
Workarounds proposed in the above links involve making the json invalid as a work around by s/true/True/ or converting json true to a string.
Stacktrace info:
Note:
See TracTickets
for help on using tickets.
I apologize, dug through the traceback and it looks like ast eval crept into our codebase to accommodate previous field values. I've replaced it with a json.loads. Thanks for your attention on this still.