diff options
| author | Josh Smeaton <josh.smeaton@gmail.com> | 2015-01-10 02:16:16 +1100 |
|---|---|---|
| committer | Josh Smeaton <josh.smeaton@gmail.com> | 2015-01-13 09:39:55 +1100 |
| commit | 21b858cb6735cdfdc695ff7b076e4cbc1981bc88 (patch) | |
| tree | e7cd589b11e37e99788a85f3ac170b2ecfabed3b /django/db/models/sql/query.py | |
| parent | f48e2258a96a08dcec843921206bcf7656e3ae45 (diff) | |
Fixed #24060 -- Added OrderBy Expressions
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index a613d8eba4..5d4538b2d9 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1691,14 +1691,14 @@ class Query(object): """ Adds items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- - possibly with a direction prefix ('-' or '?') -- or ordinals, - corresponding to column positions in the 'select' list. + possibly with a direction prefix ('-' or '?') -- or OrderBy + expressions. If 'ordering' is empty, all ordering is cleared from the query. """ errors = [] for item in ordering: - if not ORDER_PATTERN.match(item): + if not hasattr(item, 'resolve_expression') and not ORDER_PATTERN.match(item): errors.append(item) if errors: raise FieldError('Invalid order_by arguments: %s' % errors) |
