Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit e4757ec7afd54861e0c34d9b0f5edbbac4e2b860 1 parent 7efd968
@spookylukey spookylukey authored
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]
Please sign in to comment.
Something went wrong with that request. Please try again.