Reputation: 105
I'm quite new to django-oscar and i'm trying to figure out how i can create a queryset that only returns products with a certain category on a section in my template, for instance all products with the category 'electronics'.How can i go about this?
Upvotes: 0
Views: 882
Reputation: 46
Might be easiest to start with the category and then get all the category's products:
from oscar.core.loading import get_model
Category = get_model('catalogue', 'Category')
cat = Category.objects.get(name='electronics')
prods = cat.product_set.all()
Then add prods
to your response and use it in your template.
Upvotes: 3