From 42749bacd368287aa532cb7cc811ad2a989ab4c6 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Tue, 17 May 2016 21:24:04 +0200 Subject: [PATCH] get category object --- shop/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shop/views.py b/shop/views.py index 38a335c9..e6b4c4af 100644 --- a/shop/views.py +++ b/shop/views.py @@ -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,