Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: A easier way to filter with exclude=True #1557

Open
hongfanmeng opened this issue Feb 8, 2023 · 4 comments
Open

Enhancement: A easier way to filter with exclude=True #1557

hongfanmeng opened this issue Feb 8, 2023 · 4 comments

Comments

@hongfanmeng
Copy link

class ExampleFilter(FilterSet):
    id__not__in = NumberInFilter(field_name='id', lookup_expr='in', exclude=True)

is it possible to auto generate [field_name]__not__[lookup] filter ?

@hongfanmeng hongfanmeng changed the title Enhancement: A easier way for filter with exclude=True Enhancement: A easier way to filter with exclude=True Feb 8, 2023
@hongfanmeng
Copy link
Author

To be precise, I want to automatically generate suffix of all lookup with or without exclude

@aidanlister
Copy link

aidanlister commented Apr 28, 2023

I really want this too, #978 and see this discussion about it, #1484

@WhiteSage
Copy link

Hello, I have recently started used django-fliters and also stumbled upon this.

I have written some minimal mixins which enable this behavior on django-filters (tested on DRF, not sure if compatible at all with forms). You can find them here https://github.com/WhiteSage/django-filter-autotools .

@rodrigondec
Copy link

rodrigondec commented Sep 19, 2023

I invested sometime to analysed and do a extension to have automagically exclude on any lookup. Posted the snnipets here

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

No branches or pull requests

4 participants