8
8
from django import get_version as get_django_version
9
9
from django .contrib .contenttypes .models import ContentType
10
10
from django .core .exceptions import FieldDoesNotExist
11
+ from django .db .models import FilteredRelation
11
12
from django .db .models .query import ModelIterable , Q , QuerySet
12
13
13
14
from .query_translate import (
@@ -265,6 +266,8 @@ def patch_lookup(a):
265
266
# stored inside a complex query expression.
266
267
if isinstance (a , Q ):
267
268
translate_polymorphic_Q_object (self .model , a )
269
+ elif isinstance (a , FilteredRelation ):
270
+ patch_lookup (a .condition )
268
271
elif hasattr (a , "get_source_expressions" ):
269
272
for source_expression in a .get_source_expressions ():
270
273
if source_expression is not None :
@@ -290,6 +293,8 @@ def tree_node_test___lookup(my_model, node):
290
293
tree_node_test___lookup (my_model , child )
291
294
292
295
tree_node_test___lookup (self .model , a )
296
+ elif isinstance (a , FilteredRelation ):
297
+ test___lookup (a .condition )
293
298
elif hasattr (a , "get_source_expressions" ):
294
299
for source_expression in a .get_source_expressions ():
295
300
test___lookup (source_expression )
0 commit comments