#29112: Make it easier to update specific keys within nested Django JSONField 
data.
--------------------------------------------+------------------------
               Reporter:  Michael           |          Owner:  (none)
                   Type:  New feature       |         Status:  new
              Component:  contrib.postgres  |        Version:  1.11
               Severity:  Normal            |       Keywords:
           Triage Stage:  Unreviewed        |      Has patch:  0
    Needs documentation:  0                 |    Needs tests:  0
Patch needs improvement:  0                 |  Easy pickings:  0
                  UI/UX:  1                 |
--------------------------------------------+------------------------
 Django's docs have a great example of querying nested data using double
 underscore syntax similar to querying across foreign keys


 {{{
 Dog.objects.filter(data__owner__name='Bob')
 }}}

 What if we wanted to update this dogs owner's name instead (without
 touching anything else)? Rather than doing this


 {{{
 dog = Dog.objects.get(pk=n)
 data = dog.data
 data['owner']['name'] = 'Steve'
 dog.data = data
 dog.save()
 }}}

 It would be great to do this:


 {{{
 Dog.objects.filter(pk=2).update(data__owner__name='Steve')
 }}}


 Looks like django-postgres-extensions[0] attempts to do this, but I found
 the library to be unstable on 1.11.


 [0] - http://django-postgres-extensions.readthedocs.io/

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29112>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.cc0ce43018c659edd2466b3849b23c28%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to