diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index e571ef2222..ca422803a6 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -598,7 +598,7 @@ class SQLCompiler(object): for order, order_params in ordering_group_by: # Even if we have seen the same SQL string, it might have # different params, so, we add same SQL in "has params" case. - if order not in seen or params: + if order not in seen or order_params: result.append(order) params.extend(order_params) seen.add(order)