-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #544 from benjaoming/testproject-layout
Amendment to modernization of testproject
- Loading branch information
Showing
3 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.conf import settings | ||
from django.http import HttpResponseServerError | ||
from django.template import loader | ||
from django.template.context import RequestContext | ||
from django.views.decorators.csrf import requires_csrf_token | ||
|
||
|
||
@requires_csrf_token | ||
def server_error(request, template_name='500.html'): | ||
# You need to create a 500.html template. | ||
t = loader.get_template(template_name) | ||
return HttpResponseServerError(t.render(RequestContext( | ||
request, | ||
{ | ||
'MEDIA_URL': settings.MEDIA_URL, | ||
'STATIC_URL': settings.STATIC_URL, | ||
}, | ||
))) | ||
|
||
|
||
def page_not_found(request, template_name='404.html'): | ||
response = server_error(request, template_name=template_name) | ||
response.status_code = 404 | ||
return response |