from django_filters import rest_framework as filters
from .models import Consumer


class ConsumerFilter(filters.FilterSet):
    min_create = filters.DateFilter(field_name="create_time", lookup_expr='gte')
    max_create = filters.DateFilter(field_name="create_time", lookup_expr='lte')
    username__contains = filters.CharFilter(field_name='username', lookup_expr='contains')
    class Meta:
        model = Consumer
        fields = ['company', 'role', 'min_create', 'max_create', 'create_admin', 'username', 'username__contains']