Django Filter Package – Exclude Django.How

Author avatar wrote on 03/06/2022

Automatically all fields will be added but the excluded


class RequestFilter(django_filters.FilterSet):

    class Meta:
        model = Request
        exclude = ['id']


Note that this option will not disable filters declared directly on the FilterSet.

class RequestFilter(django_filters.FilterSet):
    id = django_filters.NumberFilter(label="ID",)

    class Meta:
        model = Request
        exclude = ['name', 'company']