Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Luke Plant authored December 19, 2009

Showing 1 changed file with 2 additions and 0 deletions. Show diff stats Hide diff stats

  1. 2  django/db/models/query.py
2  django/db/models/query.py
@@ -320,6 +320,8 @@ def get(self, *args, **kwargs):
320 320
         keyword arguments.
321 321
         """
322 322
         clone = self.filter(*args, **kwargs)
  323
+        if self.query.can_filter():
  324
+            clone = clone.order_by()
323 325
         num = len(clone)
324 326
         if num == 1:
325 327
             return clone._result_cache[0]

0 notes on commit e4757ec

Please sign in to comment.
Something went wrong with that request. Please try again.