Files
app-store-optimization/skills/loki-mode/benchmarks/results/2026-01-05-01-35-39/swebench-patches/django__django-13028.patch

13 lines
980 B
Diff

Based on the issue description and the hint provided, I can generate the patch. The issue is that Django's `check_filterable` method incorrectly checks for a `filterable` attribute on any object (including model instances), when it should only check for this attribute on expressions. The fix is to first verify that the object is an expression by checking for `resolve_expression` before checking the `filterable` attribute.
--- 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.'