Hello everyone,  

While developing standard web applications one thing I frequently do is 
updating just one field of a model instance and save it after that. The best 
way to do that today (if you want to avoid the update in all the fields) is 
with the code bellow.  

product.name = 'Name changed again' product.save(update_fields=['name'])  

I want to propose a shortcut for this kind of operation. I came up with two 
solutions.  

Solution One

product.save(update_fields={'name': 'Name changed again'})  

Solution Two (My preferred)

product.update_fields(name='Name changed again')  

What do you guys think about this?   
[]’s
Paulo Poiati  
blog.paulopoiati.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/af689c4f-4526-4b08-ade2-9044181e3950%40Paulos-iMac.local.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to