Ich habe ein einfaches Skript geschrieben, aber wenn ich die Schleife im Skript haben, die products
und allbrands
Variable kommt leer, außer wenn ich die Schleife entfernen. Hier ist ein Teil des Skripts.Python Django für Schleife funktioniert nicht richtig
products = amazon.search(Brand="Microsoft", SearchIndex="Software", ResponseGroup="Images,ItemAttributes,Accessories,Reviews,VariationSummary,Variations")
allbrands = Brand.objects.all();
for i, product in enumerate(products):
print ("Product");
context = {
'products': products,
'allbrands': allbrands
}
return render(request, 'storefront/index.html', context)
Danke. Das hat funktioniert – user3072613