diff --git a/pages/views.py b/pages/views.py index 0708390..a932658 100644 --- a/pages/views.py +++ b/pages/views.py @@ -1,5 +1,5 @@ +from django.http import HttpResponseRedirect, Http404 from django.utils.translation import get_language -from django.http import HttpResponseRedirect from django.views import generic from django.urls import reverse from .models import Page, PageContent @@ -16,7 +16,10 @@ class PageView(generic.DetailView): template_name = 'pages/page.html' def get_object(self): - return PageContent.objects.filter( + obj = PageContent.objects.filter( language=get_language(), page__slug=self.kwargs['slug'] ).first() + if obj is None: + raise Http404('Page not found: %s' % self.kwargs['slug']) + return obj