[Python] Specify in which order to apply filters in django_filters.FilterSet

Discussão em 'Python' iniciado por Stack, Agosto 28, 2025.

  1. Stack

    Stack Membro Participativo

    Within a django_filters.FilterSet:

    class SomeFilter(django_filters.FilterSet):
    model = SomeModel
    fields = {
    "is_archived": ("exact",),
    }

    include_ancestors = django_filters.BooleanFilter(method="include_ancestors_filter")

    def include_ancestors_filter(self, queryset, name, value):
    pass


    how can I specify that the filter field include_ancestors should be applied after all other filter fields (e.g. is_archived)?

    This is needed in my case because including the ancestors depends on the result set (i.e. depends on what children have been included based on all other filters).

    Continue reading...

Compartilhe esta Página