From: Magnus Hagander Date: Mon, 11 Jun 2018 12:13:55 +0000 (+0200) Subject: Fix fix for file not found X-Git-Tag: FINAL_PY2~306 X-Git-Url: http://git.postgresql.org/gitweb/static/benefitdownload/file?a=commitdiff_plain;h=b097909dce4c7619884a2e6305cd86f5a5772193;p=pgeu-web.git Fix fix for file not found The old one was broken for URLs with .. in them, the new one was broken for everything else. Let's see if we can get them both fixed at once. --- diff --git a/postgresqleu/static/views.py b/postgresqleu/static/views.py index 6de81a2..d27b48d 100644 --- a/postgresqleu/static/views.py +++ b/postgresqleu/static/views.py @@ -1,5 +1,5 @@ from django.http import HttpResponse, Http404 -from django.template import loader +from django.template import loader, TemplateDoesNotExist # Fallback handler for URLs not matching anything else. Fall them # back to a static template. If that one is not found, send a 404 @@ -9,6 +9,9 @@ def static_fallback(request, url): if url.find('..') > -1: raise Http404('Page not found') - t = loader.get_template('pages/%s.html' % url) - return HttpResponse(t.render()) + try: + t = loader.get_template('pages/%s.html' % url) + return HttpResponse(t.render()) + except TemplateDoesNotExist: + raise Http404('Page not found')