izimobil/django-rest-framework-datatables

Can't get filter method to work

perkalerk opened this issue · 0 comments

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.