Skip to content

Can't get filter method to work #128

@perkalerk

Description

@perkalerk

Hello,

I'm trying to filter a queryset using a method instead of field_name, but I can't get the method to be called.

Here is my code:

class CustomerMasterGlobalFilter(DatatablesFilterSet):

best_account_address = CharFilter(method='address_filter')

class Meta:
    model = CustomerMaster
    fields = ["best_account_address"]

def address_filter(self, queryset, name, value):
    print("filter called")

I realize I'm supposed to return a queryset with the method, but I can't even get the statement to print. It just doesn't do anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions