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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -