Changed get_object() not to use 'ordering' parameter from the model. Thanks, Ned Batchelder. Also updated some unit tests to show correct DoesNotExist output
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2392 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
de66a3a7da
commit
250281361d
|
@ -1352,6 +1352,7 @@ def _get_where_clause(lookup_type, table_prefix, field_name, value):
|
|||
raise TypeError, "Got invalid lookup_type: %s" % repr(lookup_type)
|
||||
|
||||
def function_get_object(opts, klass, does_not_exist_exception, **kwargs):
|
||||
kwargs['order_by'] = kwargs.get('order_by', ())
|
||||
obj_list = function_get_list(opts, klass, **kwargs)
|
||||
if len(obj_list) < 1:
|
||||
raise does_not_exist_exception, "%s does not exist for %s" % (opts.object_name, kwargs)
|
||||
|
|
|
@ -67,7 +67,7 @@ datetime.datetime(2005, 7, 28, 0, 0)
|
|||
>>> articles.get_object(id__exact=2)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ArticleDoesNotExist: Article does not exist for {'id__exact': 2}
|
||||
ArticleDoesNotExist: Article does not exist for {'order_by': (), 'id__exact': 2}
|
||||
|
||||
>>> articles.get_object(pub_date__year=2005, pub_date__month=8)
|
||||
Traceback (most recent call last):
|
||||
|
|
|
@ -45,7 +45,7 @@ Fran Bones
|
|||
>>> employees.get_object(pk='foo')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
EmployeeDoesNotExist: Employee does not exist for {'pk': 'foo'}
|
||||
EmployeeDoesNotExist: Employee does not exist for {'pk': 'foo', 'order_by': ()}
|
||||
|
||||
# Fran got married and changed her last name.
|
||||
>>> fran = employees.get_object(pk='XYZ456')
|
||||
|
|
|
@ -53,7 +53,7 @@ Demon Dogs the restaurant
|
|||
>>> p2.get_restaurant()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
RestaurantDoesNotExist: Restaurant does not exist for {'place__id__exact': ...}
|
||||
RestaurantDoesNotExist: Restaurant does not exist for {'order_by': (), 'place__id__exact': ...}
|
||||
|
||||
# restaurants.get_list() just returns the Restaurants, not the Places.
|
||||
>>> restaurants.get_list()
|
||||
|
|
Loading…
Reference in New Issue