While using any of the examples listed here, this error is thrown by django-filter:
AssertionError: The `lookup_expr` argument no longer accepts `None` or a list of expressions. Use the `LookupChoiceFilter` instead. See: https://django-filter.readthedocs.io/en/master/guide/migration.html
Then if I, as they suggest, change lookup_exp to use LookupChoiceFilter instead. Like so:
class UserFilter(django_filters.FilterSet):
name = django_filters.LookupChoiceFilter(
field_class=forms.CharField,
lookup_choices=[
('exact', 'Equals'),
]
)
class Meta:
model = User
fields = ['name']
Then my name filter shows up as name in the schema instead of expected name_Exact. GraphQL allows me to pass the name parameter, but as expected no filtering is done.
@jkimbo Shouldn't this be labeled as a bug?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Since you're only using a single lookup, it's no problem to use the following:
class UserFilter(django_filters.FilterSet):
name = CharFilter(lookup_expr='exact')
class Meta:
model = User
fields = ['name']
However, if you do want to support multiple lookups - the following set up does not work:
class UserFilter(django_filters.FilterSet):
name = LookupChoiceFilter(lookup_choices=['exact', 'icontains'])
class Meta:
model = User
fields = ['name']
Edit: but yes, in any case the documentation should be updated. Replacing lookup_type=['iexact'] with lookup_type='iexact' will at least ensure that the docs contain workable code.
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.