How can i pass a dict which contain fields to update a Django model? This is not to create an object, but to update it.
example:
obj = Object.objects.cre
This question is a little old, but just to bring it up to date with recent Django developments - since 1.7 there has been an update_or_create
method on querysets which works similarly to get_or_create
.
In this case it could be used like:
obj, created = Object.objects.update_or_create(index=id, defaults={**fields})