Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 250281361d1341bd9b9481a16f16acc49a8f142a 1 parent de66a3a
Adrian Holovaty adrianholovaty authored
1  django/core/meta/__init__.py
View
@@ -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)
2  tests/testapp/models/basic.py
View
@@ -67,7 +67,7 @@ class Article(meta.Model):
>>> 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):
2  tests/testapp/models/custom_pk.py
View
@@ -45,7 +45,7 @@ def __repr__(self):
>>> 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')
2  tests/testapp/models/one_to_one.py
View
@@ -53,7 +53,7 @@ def __repr__(self):
>>> 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()
Please sign in to comment.
Something went wrong with that request. Please try again.