summaryrefslogtreecommitdiff
path: root/docs/topics
diff options
context:
space:
mode:
authorKeryn Knight <keryn@kerynknight.com>2015-01-13 08:02:17 +0000
committerTim Graham <timograham@gmail.com>2015-01-16 09:42:03 -0500
commitbd08cfca6ff04e7cec940f5b59e97cdcceddcc69 (patch)
tree420c0116fbeff1c704d8a6a5ba58132880b9cd0e /docs/topics
parent065b2a82f6d7539032e15308351fa5eee95c0cb9 (diff)
[1.7.x] Fixed #24143 -- Encouraged use of Http404 messages for debugging.
Backport of 726a9550db5129badc1c44809b0bed728fa1ad90 from master
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/http/shortcuts.txt4
-rw-r--r--docs/topics/http/views.txt7
2 files changed, 8 insertions, 3 deletions
diff --git a/docs/topics/http/shortcuts.txt b/docs/topics/http/shortcuts.txt
index d64ec2f7cb..c167fa4762 100644
--- a/docs/topics/http/shortcuts.txt
+++ b/docs/topics/http/shortcuts.txt
@@ -299,7 +299,7 @@ This example is equivalent to::
try:
my_object = MyModel.objects.get(pk=1)
except MyModel.DoesNotExist:
- raise Http404
+ raise Http404("No MyModel matches the given query.")
The most common use case is to pass a :class:`~django.db.models.Model`, as
shown above. However, you can also pass a
@@ -369,4 +369,4 @@ This example is equivalent to::
def my_view(request):
my_objects = list(MyModel.objects.filter(published=True))
if not my_objects:
- raise Http404
+ raise Http404("No MyModel matches the given query.")
diff --git a/docs/topics/http/views.txt b/docs/topics/http/views.txt
index 41853b76ca..121c4a9423 100644
--- a/docs/topics/http/views.txt
+++ b/docs/topics/http/views.txt
@@ -121,13 +121,18 @@ Example usage::
try:
p = Poll.objects.get(pk=poll_id)
except Poll.DoesNotExist:
- raise Http404
+ raise Http404("Poll does not exist")
return render_to_response('polls/detail.html', {'poll': p})
In order to use the ``Http404`` exception to its fullest, you should create a
template that is displayed when a 404 error is raised. This template should be
called ``404.html`` and located in the top level of your template tree.
+If you provide a message when raising an ``Http404`` exception, it will appear
+in the standard 404 template displayed when :setting:`DEBUG` is ``True``. Use
+these messages for debugging purposes; they generally aren't suitable for use
+in a production 404 template.
+
.. _customizing-error-views:
Customizing error views