Sobes.tech
Junior — Senior

Bulk price adjustment for all products

livecode

Task condition

It is necessary to check whether the logic for updating the price of each product in the database is implemented correctly: the price is reduced by 5%, and then the save() method is called for each record. Evaluate whether it is possible to implement this operation more efficiently.

products = Product.objects.all()

for product in products:
    product.price *= 0.95
    product.save()