From b38d44229ff185ad156bcb443d6db0db7ae3eb98 Mon Sep 17 00:00:00 2001 From: Nicolas Baccelli Date: Fri, 5 Jun 2020 21:01:39 +0200 Subject: Fixed #31664 -- Reallowed using non-expressions having filterable attribute as rhs in queryset filters. Regression in 4edad1ddf6203326e0be4bdb105beecb0fe454c4. --- django/db/models/sql/query.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'django/db/models/sql/query.py') diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index ce18098fd2..d65141b834 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1124,7 +1124,10 @@ class Query(BaseExpression): def check_filterable(self, expression): """Raise an error if expression cannot be used in a WHERE clause.""" - if not getattr(expression, 'filterable', True): + if ( + hasattr(expression, 'resolve_expression') and + not getattr(expression, 'filterable', True) + ): raise NotSupportedError( expression.__class__.__name__ + ' is disallowed in the filter ' 'clause.' -- cgit v1.3