I’m using JSON Field with Django 2.2.13 and I’ve tried to use the update() of my Model to update a value of this json field but I’ve realised Django does not allow to update a specific value by using the same lookup strategy of filtering/getting a JSONField but under the hood Django tries to look for relationships like it does normally by using lookup fields.
I think it could be nice to have that possibility when we try to update a specific value by using the update() method.
I’d like to have feedbacks about it and I hope it will be a “sprint” for future implementations.
Do you mean a database function like
JSONInsert etc. in Django-MySQL: https://django-mysql.readthedocs.io/en/latest/database_functions.html#django_mysql.models.functions.JSONInsert ?
Looks like django.contrib.postgres never had any such functions. It’d be good to get some into core.
Thanks for your response!
Argh, sorry I forgot to mention I’m using Postgres and so JSONField from contrib.postgres.
Yup, it’d be so cool imho and so useful, especially in my current use case where I’m using the update() especially to avoid race conditions like official docs suggest.
I think you should check for any existing tickets, and if none exist, read the contributing guide, write one, and see what you can add. The main difficulty will be finding versions of the functions on all backends, since Django’s JSONField will be universal from 3.1 onwards.
Great, thanks so much for suggestions!