Raise Http404 if BlogCategory is not found

This commit is contained in:
M.Ravi 2017-12-27 16:44:38 +01:00
parent 94896db873
commit 72d134b00d

View file

@ -8,6 +8,7 @@ from django.apps import apps
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.http import Http404
from django.utils.timezone import now from django.utils.timezone import now
from django.utils.translation import get_language from django.utils.translation import get_language
from django.views.generic import DetailView, ListView from django.views.generic import DetailView, ListView
@ -177,9 +178,12 @@ class CategoryEntriesView(BaseBlogListView, ListView):
@property @property
def category(self): def category(self):
if not self._category: if not self._category:
self._category = BlogCategory.objects.active_translations( try:
get_language(), slug=self.kwargs['category'] self._category = BlogCategory.objects.active_translations(
).get() get_language(), slug=self.kwargs['category']
).get()
except BlogCategory.DoesNotExist:
raise Http404
return self._category return self._category
def get(self, *args, **kwargs): def get(self, *args, **kwargs):