Commits

Tobias McNulty committed 06ee75d

proposed fix for #13640

Comments (0)

Files changed (1)

django/db/models/sql/query.py

 from django.db import connections, DEFAULT_DB_ALIAS
 from django.db.models import signals
 from django.db.models.fields import FieldDoesNotExist
+from django.db.models.expressions import ExpressionNode
 from django.db.models.query_utils import select_related_descend, InvalidQuery
 from django.db.models.sql import aggregates as base_aggregates_module
 from django.db.models.sql.constants import *
             value = True
         elif callable(value):
             value = value()
-        elif hasattr(value, 'evaluate'):
+        elif isinstance(value, ExpressionNode):
             # If value is a query expression, evaluate it
             value = SQLEvaluator(value, self)
             having_clause = value.contains_aggregate