Reputation: 109
Provided this python code for a Shopify app:
with request.user.session:
products = shopify.Product.find()
for product in products:
if product.variants.0.inventory_management:
make_call()
So, when I use product.variants.0.inventory_management in my view file called "home.html", it displays the value "shopify" which makes sense. But when I use the exact same thing in the code example above I get a syntax error and my django app shows the error log. How do I fix this?
Upvotes: 0
Views: 60
Reputation: 599490
variants
is presumably a list. In python you use square brackets to index a list:
if product.variants[0].inventory_management:
Upvotes: 1