13 lines
957 B
Diff
13 lines
957 B
Diff
This appears to be a Django issue that needs to be applied to the Django repository. Based on the issue description and the provided hint, I can generate the patch directly. The fix is clear from the hint - we need to check if the expression has `resolve_expression` attribute before checking the `filterable` attribute, to avoid false positives when a model happens to have a field named `filterable`.
|
|
|
|
--- a/django/db/models/sql/query.py
|
|
+++ b/django/db/models/sql/query.py
|
|
@@ -1124,7 +1124,7 @@ 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.'
|