summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index e5524a8198..82ff6bf4ea 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1895,7 +1895,16 @@ class Query(BaseExpression):
"""
errors = []
for item in ordering:
- if not hasattr(item, 'resolve_expression') and not ORDER_PATTERN.match(item):
+ if isinstance(item, str) and ORDER_PATTERN.match(item):
+ if '.' in item:
+ warnings.warn(
+ 'Passing column raw column aliases to order_by() is '
+ 'deprecated. Wrap %r in a RawSQL expression before '
+ 'passing it to order_by().' % item,
+ category=RemovedInDjango40Warning,
+ stacklevel=3,
+ )
+ elif not hasattr(item, 'resolve_expression'):
errors.append(item)
if getattr(item, 'contains_aggregate', False):
raise FieldError(