enhance automatic filter lookups #1474
-
The docs specify that the filters can be automatically built from either a list of fields or Is it not possible to fetch all possible lookups like: {field.name, list(field.class_lookups)) for field in model._meta.fields} or have i not understood something? many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
See Generating filters with Meta.fields in the usage guide. If you want to customise the lookups you can pass a dict (or declare the equivalent filters manually): class ProductFilter(django_filters.FilterSet):
class Meta:
model = Product
fields = {
'price': ['lt', 'gt'],
'release_date': ['exact', 'year__gt'],
}
How you generate that dict is up to you. See also |
Beta Was this translation helpful? Give feedback.
See Generating filters with Meta.fields in the usage guide.
If you want to customise the lookups you can pass a dict (or declare the equivalent filters manually):
How you generate that dict is up to you.
See also
LookupChoiceFilter