From 900bce6bc3952c9da0d3675af9844600ca90874b Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Tue, 17 May 2016 21:10:01 +0200 Subject: [PATCH] only show public categories --- shop/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shop/views.py b/shop/views.py index 53f0916e..38a335c9 100644 --- a/shop/views.py +++ b/shop/views.py @@ -90,6 +90,8 @@ class ShopIndexView(ListView): if 'category' in self.request.GET: category = self.request.GET.get('category') + if not category.public: + raise Http404("Category not found") context['products'] = context['products'].filter( category__slug=category, public=True, @@ -98,7 +100,8 @@ class ShopIndexView(ListView): context['categories'] = ProductCategory.objects.annotate( num_products=Count('products') ).filter( - num_products__gt=0 + num_products__gt=0, + public=True, ) return context