I have the following code:
obj = Products.objects.filter(dump__product_name = 'ABC, dump__product_color = 'black').values()
new_price = [100, 200, 300]
for item in range(len(obj)):
obj[item]['price'] -= new_price[item]
Products.objects.filter(dump__product_name = 'ABC, dump__product_color = 'black').bulk_update(obj, ['price'])
But I am getting the error, Exception inside application: 'dict' has no attribute 'pk'
The value of obj looks like this:
<QuerySet [{'id': 1, 'product_name': 'Acer - Laptop', 'price': 350},
{'id': 1, 'product_name': 'Dell - Laptop', 'price': 450},
{'id': 1, 'product_name': 'Samsung- Laptop', 'price': 650}]>
I am unable to figure out what's wrong with the code. Any help would be much appreciated. Thanks a lot in advance