summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorDavid Sanders <shang.xiao.sanders@gmail.com>2022-09-18 01:44:37 +1000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-10-04 08:19:34 +0200
commit4771a1694b3b54c7309602820881d3ec9cc2c809 (patch)
tree68b16c5811caf7d67e1f3425bbedb6e81181ead1 /django/db/models/sql/query.py
parent649b28eab6765cd6b2b40c779a18ecafc99b43d7 (diff)
Fixed #34012 -- Made QuerySet.order_by() apply transforms on related fields for models with Meta.ordering.
This makes QuerySet.order_by() no longer ignore trailing transforms for models with Meta.ordering. As a consequence, FieldError is raised in such cases for non-existent fields. Thanks to Klaas van Schelven for the report and Mariusz Felisiak for the review and advice.
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 12cb390e98..61e39b5153 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1819,6 +1819,7 @@ class Query(BaseExpression):
final_transformer = functools.partial(
transform, name=name, previous=final_transformer
)
+ final_transformer.has_transforms = True
# Then, add the path to the query's joins. Note that we can't trim
# joins at this stage - we will need the information about join type
# of the trimmed joins.