From 6cc0eda1cb665e680ae29307a72c7cea1926cb52 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 20 Mar 2007 16:48:41 +0000 Subject: [PATCH] Fixed #3767 -- Added reason to Http404 exception raised in get_object_or_404 and get_list_or_404 git-svn-id: http://code.djangoproject.com/svn/django/trunk@4756 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/shortcuts/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django/shortcuts/__init__.py b/django/shortcuts/__init__.py index be2155bb09..81381d08c1 100644 --- a/django/shortcuts/__init__.py +++ b/django/shortcuts/__init__.py @@ -19,7 +19,7 @@ def get_object_or_404(klass, *args, **kwargs): try: return manager.get(*args, **kwargs) except klass.DoesNotExist: - raise Http404 + raise Http404('No %s matches the given query.' % klass._meta.object_name) def get_list_or_404(klass, *args, **kwargs): if isinstance(klass, Manager): @@ -28,5 +28,5 @@ def get_list_or_404(klass, *args, **kwargs): manager = klass._default_manager obj_list = list(manager.filter(*args, **kwargs)) if not obj_list: - raise Http404 + raise Http404('No %s matches the given query.' % manager.model._meta.object_name) return obj_list