Fixed #12258 - QuerySet.get() should clear ordering.

We only clear ordering when doing so cannot change the result returned by
the get() method i.e.  when the query does not already define limits.

Thanks to mattdennewitz@gmail.com for the report, and jdunck for the patch



git-svn-id: http://code.djangoproject.com/svn/django/trunk@11916 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Luke Plant 2009-12-19 15:02:46 +00:00
parent 7efd96844d
commit e4757ec7af
1 changed files with 2 additions and 0 deletions

View File

@ -320,6 +320,8 @@ class QuerySet(object):
keyword arguments.
"""
clone = self.filter(*args, **kwargs)
if self.query.can_filter():
clone = clone.order_by()
num = len(clone)
if num == 1:
return clone._result_cache[0]