Skip to content

Conversation

RouganStriker
Copy link

Allow AutoFilter to accept a method param and pass it to the generated filters.

The same behaviour for the following

class MyFilter(FilterSet):
    title__contains = CharFilter(method='custom_pk_filter')
    title__endswith = CharFilter(method='custom_pk_filter')

    def custom_pk_filter(self, qs, field, value):
        pass

Can now be done as

class MyFilter(FilterSet):
    title = AutoFilter(lookups=['contains', 'endswith'], method='custom_pk_filter')

    def custom_pk_filter(self, qs, field, value):
        pass

@rpkilby
Copy link
Collaborator

rpkilby commented Mar 25, 2020

Thanks for submitting this. For now, this is blocked by carltongibson/django-filter#1150, which would make the field_name/lookup_expr workaround unnecessary.

@rpkilby rpkilby mentioned this pull request Aug 8, 2020
@SunnyR SunnyR deleted the tech/pas/198_drf_filters branch June 7, 2024 03:33
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.71%. Comparing base (a6fc693) to head (9a3cfa3).
Report is 10 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants