Skip to content

Commit d69551a

Browse files
committed
Add compatibility with older django/python versions
1 parent 1f0f0ad commit d69551a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rest_framework/filters.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ def construct_search(self, field_name, queryset):
9696
if hasattr(field, "path_infos"):
9797
# Update opts to follow the relation.
9898
opts = field.path_infos[-1].to_opts
99+
# django < 4.1
100+
elif hasattr(field, 'get_path_info'):
101+
# Update opts to follow the relation.
102+
opts = field.get_path_info()[-1].to_opts
99103
# Otherwise, use the field with icontains.
100104
lookup = 'icontains'
101105
return LOOKUP_SEP.join([field_name, lookup])

0 commit comments

Comments
 (0)