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
This commit is contained in:
parent
55a67ae3f0
commit
6cc0eda1cb
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue