Permalink
Browse files

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
  • Loading branch information...
1 parent 7efd968 commit e4757ec7afd54861e0c34d9b0f5edbbac4e2b860 @spookylukey spookylukey committed Dec 19, 2009
Showing with 2 additions and 0 deletions.
  1. +2 −0 django/db/models/query.py
View
2 django/db/models/query.py
@@ -320,6 +320,8 @@ def get(self, *args, **kwargs):
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]

0 comments on commit e4757ec

Please sign in to comment.