mirror of
https://github.com/django/django.git
synced 2025-09-24 19:23:03 +00:00
Fixed #10494 -- Added kwargs to QuerySet.get() error message in the case no objects were found.
Thanks brondsem for the report, Szymon Pyzalski for the patch and oinopion for review. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17917 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a901654a96
commit
d5b93d3281
4 changed files with 24 additions and 10 deletions
|
@ -363,10 +363,14 @@ class QuerySet(object):
|
|||
if num == 1:
|
||||
return clone._result_cache[0]
|
||||
if not num:
|
||||
raise self.model.DoesNotExist("%s matching query does not exist."
|
||||
% self.model._meta.object_name)
|
||||
raise self.model.MultipleObjectsReturned("get() returned more than one %s -- it returned %s! Lookup parameters were %s"
|
||||
% (self.model._meta.object_name, num, kwargs))
|
||||
raise self.model.DoesNotExist(
|
||||
"%s matching query does not exist. "
|
||||
"Lookup parameters were %s" %
|
||||
(self.model._meta.object_name, kwargs))
|
||||
raise self.model.MultipleObjectsReturned(
|
||||
"get() returned more than one %s -- it returned %s! "
|
||||
"Lookup parameters were %s" %
|
||||
(self.model._meta.object_name, num, kwargs))
|
||||
|
||||
def create(self, **kwargs):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue