From a7f1f14dc779173fc9f4dc9411748b886170c69a Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Thu, 19 Apr 2018 09:12:54 +0200 Subject: [PATCH] Raise Http404 when we do not have a post for a given language --- digitalglarus/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/digitalglarus/views.py b/digitalglarus/views.py index 32d8e1f5..a450b413 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -2,7 +2,7 @@ import logging from django.conf import settings from django.shortcuts import render -from django.http import HttpResponseRedirect +from django.http import HttpResponseRedirect, Http404 from django.core.urlresolvers import reverse_lazy, reverse from django.utils.translation import ugettext_lazy as _ from django.views.generic import TemplateView, UpdateView @@ -846,6 +846,8 @@ def blog_detail(request, slug): # post = Post.objects.filter_by_language(get_language()).filter(slug=slug).first() post = Post.objects.translated(get_language(), slug=slug).first() + if post is None: + raise Http404() context = { 'post': post, }