On Wed, Mar 5, 2014 at 2:05 PM, Paulo Poiati <paulogpoi...@gmail.com> wrote: > 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') > >
Solution Three (existing) Product.objects.filter(pk=product.pk).update(name='Name changed again') ? Cheers Tom -- 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/CAFHbX1%2Bxf77_vMPK881gaQuE9EKf6uyKiZHEMS%2BMPev3hWzQNw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.