summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorAnssi Kääriäinen <anssi.kaariainen@thl.fi>2016-01-20 11:05:48 +0200
committerTim Graham <timograham@gmail.com>2016-01-20 19:16:18 -0500
commit05e8fa83c378c882ab4d4a1012ce954a9dced6de (patch)
tree4e610010630b0ae442188e8d553cd94c130edf10 /django/db/models/sql
parent076d4591108764695582ab272fdb7f348b4c161c (diff)
[1.9.x] Fixed #26092 -- Fixed QuerySet.order_by() regression with an M2M through model.
Backport of ee596888e1149864e7828f5cf63c0eda395744c3 from master
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/compiler.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 48b00461e9..22e4e884b8 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -568,7 +568,7 @@ class SQLCompiler(object):
# If we get to this point and the field is a relation to another model,
# append the default ordering for that model unless the attribute name
# of the field is specified.
- if field.is_relation and path and opts.ordering and name != field.attname:
+ if field.is_relation and opts.ordering and getattr(field, 'attname', None) != name:
# Firstly, avoid infinite loops.
if not already_seen:
already_seen = set()