I've an object:-
a = Model.objects.get(id=1)
and a dictionary of data attributes of object a
.
update_data = {
colA: 1,
colB: 2,
colC: 3,
}
Now, I want to update object a
. How can I do it?
Note:- .update()
works on queryset, not on the object. Also, I cannot do a.colA=1
because in that case, I've use setattr
on each key.
Is there any way that I can update the object directly?