Created
April 27, 2020 17:57
-
-
Save susmithagudapati/39733a07f2894cd27b611f54b04192b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python's implementation | |
products = Product.objects.filter(category__name='shoes') | |
for product in products: | |
product.stock += 5 | |
product.save() | |
# SQL incrementing using F() method. | |
Product.objects.filter(category__name='shoes').update(stock=F('stock') + 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment