#35525: Django error with parsing JSONField
-------------------------------------+-------------------------------------
Reporter: Nirjal Paudel | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
Models,fields,encoding,decoding | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* resolution: => wontfix
* status: new => closed
Comment:
> So I had a django JSONField table with column called logs which is a
json field [ Not jsonb field ].
Django doesn't support pointing fields designed to work with certain
database data types to others, `JSONField` is not exception.
> Instead of doing this, why don't we check if the content/value parsed
from db is list or dict, by default python types for json
> If yes - Don't do anything
> If no and is a string instance - then perform json.loads() to it
If you need this feature simply subclass `JSONField` and override it's
`from_db_value` method. Note that if you use this approach you won't be
able to implement support for the `decoder` option as this requires the
decoding to be performed by the field itself and not from psycopg.
--
Ticket URL: <https://code.djangoproject.com/ticket/35525#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107019016cc4c55-5a9a0810-6a7d-4465-bfed-f97050f4745b-000000%40eu-central-1.amazonses.com.