Thanks. Was hoping there was a method for appending to a JSON array stored in a JSONField without fetching the whole record first.
On Thursday, 16 February 2017 16:24:06 UTC, ludovic coues wrote: > > You can't. > > There is 7 value types in JSON. > 3 of them are constant, true, false and null. Appending to them make no > sense. > You could append to number, but then you change its value. > String are double quote delimited. You can't append to it, you need to > insert before the closing double quote. aka updating. > Any way, I'm pretty sure JSONField don't let you use these values as > root object for some reason. > > The two remaining value types are array and object. Both suffer from > the same issue as string, they are delimited and you can't simply > append at the end, you need to insert data, aka updating. > > > If you know what you are doing, read the source, look at how to update > the raw value, write some test to make sure what you are doing is > working now and is working each time you upgrade django. > > I wish you good luck if you go down that path and to have a good > experience. > > 2017-02-16 16:53 GMT+01:00 chris jess <chri...@gmail.com <javascript:>>: > > Can anyone let me know the best way to append to a models.JSONField on > HTTP > > POST? > > > > I would prefer to simply append to the existing JSONField as opposed to > > updating the values in it. > > > > Is it possible to do this without first loading that object? > > > > Thanks. > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Django users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to django-users...@googlegroups.com <javascript:>. > > To post to this group, send email to django...@googlegroups.com > <javascript:>. > > Visit this group at https://groups.google.com/group/django-users. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/django-users/2c044960-3a7a-4997-ba43-eeb7b1747566%40googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > Cordialement, Coues Ludovic > +336 148 743 42 > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f39ffbe6-e1e2-457f-9298-932ee2574306%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.