Added custom 404/500 error templates

This commit is contained in:
Felipe Martín 2015-06-27 15:38:05 +02:00
parent c0b398a125
commit 935892620f
4 changed files with 67 additions and 2 deletions

View File

@ -1,3 +1,28 @@
from django.shortcuts import render
# coding: utf-8
# Create your views here.
# py3
from __future__ import unicode_literals
# django
from django.shortcuts import render_to_response
from django.template import RequestContext
def error404(request):
template = '404.html'
response = render_to_response(
template,
context_instance=RequestContext(request)
)
response.status_code = 404
return response
def error500(request):
template = '500.html'
response = render_to_response(
template,
context_instance=RequestContext(request)
)
response.status_code = 500
return response

View File

@ -0,0 +1,18 @@
{% extends "_layout.html" %}
{% load i18n %}
{% block page_title %}AmiiboFindr{% endblock %}
{% block main_content %}
{% url 'home' as url_home %}
<div class="ui page grid">
<div class="sixteen wide column">
<h1>{% trans "Not found!" %}</h1>
<p class="ui segment">
{% blocktrans with url_home=url_home %}
Ooooopsie. We didn't find what you're looking for. <a href="{{ url_home }}">Go back to the home page</a>.
{% endblocktrans %}
</p>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,18 @@
{% extends "_layout.html" %}
{% load i18n %}
{% block page_title %}AmiiboFindr{% endblock %}
{% block main_content %}
<div class="ui page grid">
<div class="sixteen wide column">
<h1>{% trans "Server error" %}</h1>
<p class="ui segment">
{% url 'home' as url_home %}
{% blocktrans with url_home=url_home %}
There was a server issue. Our developers have been informed of this. Please try refreshing the page or <a href="{{ url_home }}">go back to the home page</a>.
{% endblocktrans %}
</p>
</div>
</div>
{% endblock %}

View File

@ -21,6 +21,10 @@ from django.conf import settings
from django.conf.urls.static import static
handler404 = 'amiibofindr.apps.core.views.error404'
handler500 = 'amiibofindr.apps.core.views.error500'
urlpatterns = patterns(
'',
url(r'^amiibofindr-admin/', include(admin.site.urls)),