get category object

This commit is contained in:
Thomas Steen Rasmussen 2016-05-17 21:24:04 +02:00
parent 900bce6bc3
commit 42749bacd3
1 changed files with 5 additions and 1 deletions

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,