Django How to give 2 field names in filters.py date filter

115 Views Asked by At

In filters.py Here i want to give 2 field names in start date

class enquiryFilter(django_filters.FilterSet):
    start_date = DateFilter(field_name="updated_at", lookup_expr='gte',label='From',widget=DateInput(attrs={'type': 'date','id':'start_date'}))
    
1

There are 1 best solutions below

0
On

The two fields are date field using 'and', 'or' conditions we can give 2 field names in one filter

class enquiryFilter(django_filters.FilterSet):
    start_date = DateFilter(field_name="updated_at" and "created_at", lookup_expr='gte',label='From',widget=DateInput(attrs={'type': 'date','id':'start_date'}))