Add Django-1.2.1
[frozenviper.git] / Django-1.2.1 / django / views / defaults.py
blob68b9ad697c6de4fe8ac86242b1b8ddd7f35b36df
1 from django import http
2 from django.template import Context, RequestContext, loader
4 def page_not_found(request, template_name='404.html'):
5 """
6 Default 404 handler.
8 Templates: `404.html`
9 Context:
10 request_path
11 The path of the requested URL (e.g., '/app/pages/bad_page/')
12 """
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'):
17 """
18 500 error handler.
20 Templates: `500.html`
21 Context: None
22 """
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
33 # installed.
34 from django.contrib.contenttypes.views import shortcut as real_shortcut
35 return real_shortcut(request, content_type_id, object_id)