Mohamed Feddad

65%
Flag icon
it is better to use F() expressions to avoid a race condition. F() expressions avoid the need to pull the value from the database to Python memory and back. Consider the following instance: from django.db.models import F   feed = Feed.objects.get(id=id) feed.subscribers = F('subscribers') + 1 feed.save() It is only when the save() operation is performed that the increment operation is converted to an SQL expression and executed within the database.
Django Design Patterns and Best Practices: Industry-standard web development techniques and solutions using Python, 2nd Edition
Rate this book
Clear rating