In the doc, F() is used to update a single field atomically in one go.
Can I use it to update multiple fields and mixed it with non-F() field
updates?

Using the example from doc (http://docs.djangoproject.com/en/dev/ref/
models/instances/#updating-attributes-based-on-existing-fields)

Can I do something like this -

>>> from django.db.models import F
>>> product = Product.objects.get(name='Venezuelan Beaver Cheese')
>>> product.number_sold = F('number_sold') + 1
>>> product.total_sales = F('total_sales') + 199.99
>>> product.name = 'Cheddar Cheese
>>> product.save()

When product.save() is executed in the above example, will both
number_sold & total_sales be updated atomically & name updated to
'Cheddar Cheese'?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to