Skip to content

Commit e88dada

Browse files
bhatiatanishtapaswenipathak
authored andcommitted
Custom Error Pages for 403, 404 and 500
1 parent ce318c9 commit e88dada

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

oshc/main/templates/403.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% extends 'base.html' %}
2+
{% load static %}
3+
{% block content %}
4+
<section class="main-section">
5+
<div class="container">
6+
<div class="jumbotron text-center">
7+
<h1>403</h1>
8+
<h4>Permission Denied. You don't have access to this file.</h4>
9+
<br />
10+
<a href="#" onClick="history.go(-1); return false;" class="btn btn-default">Go Back</a>
11+
</div>
12+
</div>
13+
</section>
14+
{% endblock %}

oshc/main/templates/404.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% extends 'base.html' %}
2+
{% load static %}
3+
{% block content %}
4+
<section class="main-section">
5+
<div class="container">
6+
<div class="jumbotron text-center">
7+
<h1>404</h1>
8+
<h4>Woops! Page not found.</h4>
9+
<br />
10+
<a href="#" onClick="history.go(-1); return false;" class="btn btn-default">Go Back</a>
11+
</div>
12+
</div>
13+
</section>
14+
{% endblock %}

oshc/main/templates/500.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% extends 'base.html' %}
2+
{% load static %}
3+
{% block content %}
4+
<section class="main-section">
5+
<div class="container">
6+
<div class="jumbotron text-center">
7+
<h1>500</h1>
8+
<h4>Internal Server Error.</h4>
9+
<br />
10+
<a href="#" onClick="history.go(-1); return false;" class="btn btn-default">Go Back</a>
11+
</div>
12+
</div>
13+
</section>
14+
{% endblock %}

oshc/main/views.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from django.shortcuts import render
22

3+
from django.shortcuts import render_to_response
4+
5+
from django.template import RequestContext
6+
37
from main.models import chatSession
48

59

@@ -11,3 +15,24 @@ def home(request):
1115

1216
def request_session(request):
1317
return render(request, 'session.html')
18+
19+
20+
def handler404(request):
21+
response = render_to_response('404.html', {},
22+
context_instance=RequestContext(request))
23+
response.status_code = 404
24+
return response
25+
26+
27+
def handler500(request):
28+
response = render_to_response('500.html', {},
29+
context_instance=RequestContext(request))
30+
response.status_code = 500
31+
return response
32+
33+
34+
def handler403(request):
35+
response = render_to_response('403.html', {},
36+
context_instance=RequestContext(request))
37+
response.status_code = 403
38+
return response

0 commit comments

Comments
 (0)