1 from django
import http
2 from django
.template
import Context
, RequestContext
, loader
4 def page_not_found(request
, template_name
='404.html'):
11 The path of the requested URL (e.g., '/app/pages/bad_page/')
13 t
= loader
.get_template(template_name
) # You need to create a 404.html template.
14 return http
.HttpResponseNotFound(t
.render(RequestContext(request
, {'request_path': request
.path
})))
16 def server_error(request
, template_name
='500.html'):
23 t
= loader
.get_template(template_name
) # You need to create a 500.html template.
24 return http
.HttpResponseServerError(t
.render(Context({})))
26 def shortcut(request
, content_type_id
, object_id
):
27 # TODO: Remove this in Django 2.0.
28 # This is a legacy view that depends on the contenttypes framework.
29 # The core logic was moved to django.contrib.contenttypes.views after
30 # Django 1.0, but this remains here for backwards compatibility.
31 # Note that the import is *within* this function, rather than being at
32 # module level, because we don't want to assume people have contenttypes
34 from django
.contrib
.contenttypes
.views
import shortcut
as real_shortcut
35 return real_shortcut(request
, content_type_id
, object_id
)