404 fix attempt

This commit is contained in:
Philip Sargent 2021-03-25 16:15:58 +00:00
parent 8723d62add
commit 80874887cc
4 changed files with 36 additions and 1 deletions

View File

@ -23,6 +23,14 @@ Also has code to download a logbook in a choice of formats (why?!) and to
download all QMs (not working)
"""
def troggle404(request): # cannot get this to work. Handler404 in urls.py not right syntax
'''Custom 404 page to be used even when Debug=True
https://blog.juanwolf.fr/posts/programming/how-to-create-404-page-django/
'''
context = RequestContext(request)
#context['caves'] = Cave.objects.all()
return render_to_response('404.html', context.flatten())
def showrequest(request):
return HttpResponse(request.GET)

View File

@ -2,9 +2,13 @@ System check identified some issues:
WARNINGS:
?: (security.W004) You have not set a value for the SECURE_HSTS_SECONDS setting. If your entire site is served only over SSL, you may want to consider setting a value and enabling HTTP Strict Transport Security. Be sure to read the documentation first; enabling HSTS carelessly can cause serious, irreversible problems.
?: (security.W008) Your SECURE_SSL_REDIRECT setting is not set to True. Unless your site should be available over both SSL and non-SSL connections, you may want to either set this setting True or configure a load balancer or reverse-proxy server to redirect all connections to HTTPS.
?: (security.W012) SESSION_COOKIE_SECURE is not set to True. Using a secure-only session cookie makes it more difficult for network traffic sniffers to hijack user sessions.
?: (security.W018) You should not have DEBUG set to True in deployment.
?: (security.W019) You have 'django.middleware.clickjacking.XFrameOptionsMiddleware' in your MIDDLEWARE_CLASSES, but X_FRAME_OPTIONS is not set to 'DENY'. The default is 'SAMEORIGIN', but unless there is a good reason for your site to serve other parts of itself in a frame, you should change it to 'DENY'.
System check identified 5 issues (0 silenced).

23
templates/404.html Normal file
View File

@ -0,0 +1,23 @@
{% extends "base.html" %}
{% load wiki_markup %}
{% load link %}
{% block title %}List of survex files{% endblock %}
{% block content %}
<h1>404 - Page not found </h1>
<h3>Kataster number not found :{{cave}}</h3>
<p>More helpful information will appear here when someone programs it.</p>
<p>
Custom 404 page template/404.html is only activated when DEBUG=False in Django settings.
So this is of very limited usefulness to us as we do not do that with troggle, even in production.
Instead we do not raise the http404 exception in our code, we call our own error-handling display page.
We have not yet done this with all our code though..
<p>
<p><em>This page created 25 March 2021</em></p>
{% endblock %}

View File

@ -30,7 +30,7 @@
<p>
<table style="font-family: Consolas, Lucida Console, monospace;">
<tr><th>Path</th><th>Code</th><th>Type</th></tr>
<tr><th>Code</th><th>Path</th><th>Type</th></tr>
{% for c,p,t in bypathslist %}
<tr>
<td>