get category object

This commit is contained in:
Thomas Steen Rasmussen 2016-05-17 21:24:04 +02:00
parent 900bce6bc3
commit 42749bacd3

View file

@ -90,7 +90,11 @@ class ShopIndexView(ListView):
if 'category' in self.request.GET:
category = self.request.GET.get('category')
if not category.public:
try:
categoryobj = ProductCategory.objects.get(slug='category')
if not categoryobj.public:
raise Http404("Category not found")
except ProductCategory.DoesNotExist:
raise Http404("Category not found")
context['products'] = context['products'].filter(
category__slug=category,