python - Django how to update more than a row field at once -
the code below fine updating row field:
t = theform.objects.get(id=1) t.value = 1 t.save()
but if need update 5-6 fields @ once? there direct way?
like update (value=1,value2=2)
edit
i know can do:
t.value1 = 1 t.value2 = 1 t.value3 = 1
but looking single line command insert 1 instance. (theform(value1=1,value2=2,value3=3)
)
sure!
t.value1 = 1 t.value2 = 2 t.save()
alternatively,
theform.objects.filter(id=1).update(value=1, value2=2)
(and use **kwargs
here)
Comments
Post a Comment