Kaydet (Commit) dc4f726d authored tarafından Adrian Holovaty's avatar Adrian Holovaty

Fixed #688 -- Changed default 404 and 500 views to use RequestContext

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3179 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 92571b0d
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.template import Context, loader from django.template import RequestContext, loader
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django import http from django import http
...@@ -76,7 +76,7 @@ def page_not_found(request, template_name='404.html'): ...@@ -76,7 +76,7 @@ def page_not_found(request, template_name='404.html'):
The path of the requested URL (e.g., '/app/pages/bad_page/') The path of the requested URL (e.g., '/app/pages/bad_page/')
""" """
t = loader.get_template(template_name) t = loader.get_template(template_name)
return http.HttpResponseNotFound(t.render(Context({'request_path': request.path}))) return http.HttpResponseNotFound(t.render(RequestContext(request, {'request_path': request.path})))
def server_error(request, template_name='500.html'): def server_error(request, template_name='500.html'):
""" """
...@@ -86,4 +86,4 @@ def server_error(request, template_name='500.html'): ...@@ -86,4 +86,4 @@ def server_error(request, template_name='500.html'):
Context: None Context: None
""" """
t = loader.get_template(template_name) t = loader.get_template(template_name)
return http.HttpResponseServerError(t.render(Context())) return http.HttpResponseServerError(t.render(RequestContext(request)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment