From e4757ec7afd54861e0c34d9b0f5edbbac4e2b860 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Sat, 19 Dec 2009 15:02:46 +0000 Subject: [PATCH] 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 --- django/db/models/query.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django/db/models/query.py b/django/db/models/query.py index ab85bdc348..84af1bec60 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -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]