1👍
✅
While filter_name
is a variable, you did not define filter_name__icontains
. You can use string formatting for this:
queryset = queryset.filter(**{f'{filter_name}__icontains': term.get(filter_name)})
Source:stackexchange.com