Skip to content

Commit 15e2f34

Browse files
jmfedericovdboor
authored andcommitted
Fix FilteredRelation transformation
#474
1 parent 3127ad4 commit 15e2f34

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

polymorphic/query.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from django import get_version as get_django_version
99
from django.contrib.contenttypes.models import ContentType
1010
from django.core.exceptions import FieldDoesNotExist
11+
from django.db.models import FilteredRelation
1112
from django.db.models.query import ModelIterable, Q, QuerySet
1213

1314
from .query_translate import (
@@ -265,6 +266,8 @@ def patch_lookup(a):
265266
# stored inside a complex query expression.
266267
if isinstance(a, Q):
267268
translate_polymorphic_Q_object(self.model, a)
269+
elif isinstance(a, FilteredRelation):
270+
patch_lookup(a.condition)
268271
elif hasattr(a, "get_source_expressions"):
269272
for source_expression in a.get_source_expressions():
270273
if source_expression is not None:
@@ -290,6 +293,8 @@ def tree_node_test___lookup(my_model, node):
290293
tree_node_test___lookup(my_model, child)
291294

292295
tree_node_test___lookup(self.model, a)
296+
elif isinstance(a, FilteredRelation):
297+
test___lookup(a.condition)
293298
elif hasattr(a, "get_source_expressions"):
294299
for source_expression in a.get_source_expressions():
295300
test___lookup(source_expression)

0 commit comments

Comments
 (0)