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 on the model that I'd like to do an update_or_create for, but in the case where there's an existing instance and I'd be performing an update, I'd like the merge the existing JSON data with the data I'm passing to my defaults. One way I can imagine solving for this case is to pass the existing model instance to callables defined in the defaults dictionary, if an existing model instance is found. This does feel a little gross, since you'll need to check if the passed value is None, so definitely open to other suggestion.s. Wanted to post this here before on Trac to see if there's interest, better solutions, or any concerns. Thanks! -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/f44a3f50-1d01-467f-988e-8d43537a8f98n%40googlegroups.com.