Raise Http404 if BlogCategory is not found
This commit is contained in:
parent
94896db873
commit
72d134b00d
1 changed files with 7 additions and 3 deletions
|
@ -8,6 +8,7 @@ from django.apps import apps
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import Http404
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import get_language
|
||||
from django.views.generic import DetailView, ListView
|
||||
|
@ -177,9 +178,12 @@ class CategoryEntriesView(BaseBlogListView, ListView):
|
|||
@property
|
||||
def category(self):
|
||||
if not self._category:
|
||||
try:
|
||||
self._category = BlogCategory.objects.active_translations(
|
||||
get_language(), slug=self.kwargs['category']
|
||||
).get()
|
||||
except BlogCategory.DoesNotExist:
|
||||
raise Http404
|
||||
return self._category
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
|
|
Loading…
Reference in a new issue