Re: Pass existing model Instance to update_or_create callables

2020-10-28 Thread James Pulec
obj.json_field = merge_json(obj.json_field, fresh_json) > obj.save() > > If you look inside update_or_create you'll see it essentially does this > already. If you use the pattern frequently, you can always wrap it up in > your own method. > > On Mon, 26 Oct 2020 at

Pass existing model Instance to update_or_create callables

2020-10-26 Thread James Pulec
Since update_or_create supports callables in the defaults dictionary, I'm wondering if it's worth considering passing the existing instance (if one is found) to those callables when resolving them. The scenario I'm running into involves wanting to merge json data. Basically, I have a JSON field