Based on the documentation for django-filters to use excludes I have a filter that allows custom filtering for multiple fields to search to match text (exact
or contains
).
I'm trying to extend this to allow the text to be excluded from the search. i.e search for columns NOT containing text.
This is not what I want to do, I want the filter to essentially work like:
Table.filter(col1__contains='text', col2='text2').exclude(col3='text3')
Similar to but need an example that works for exact, matching and exclusive searches. How to use Django filter's exclude argument with user input?
You probably want to use a custom filter method:
You can also wrap it all up in a custom filter field if you intended to re-use it, something like this (untested):