filter.py 1.1 KB

123456789101112131415161718192021222324
  1. from django_filters import FilterSet
  2. from .models import ListModel, TypeListModel
  3. class Filter(FilterSet):
  4. class Meta:
  5. model = ListModel
  6. fields = {
  7. "id": ['exact', 'iexact', 'gt', 'gte', 'lt', 'lte', 'isnull', 'in', 'range'],
  8. "staff_name": ['exact', 'iexact', 'contains', 'icontains'],
  9. "staff_type": ['exact', 'iexact', 'contains', 'icontains'],
  10. "check_code": ['exact'],
  11. "create_time": ['year', 'month', 'day', 'week_day', 'gt', 'gte', 'lt', 'lte', 'range'],
  12. "update_time": ['year', 'month', 'day', 'week_day', 'gt', 'gte', 'lt', 'lte', 'range']
  13. }
  14. class TypeFilter(FilterSet):
  15. class Meta:
  16. model = TypeListModel
  17. fields = {
  18. "id": ['exact', 'iexact', 'gt', 'gte', 'lt', 'lte', 'isnull', 'in', 'range'],
  19. "staff_type": ['exact', 'iexact', 'contains', 'icontains'],
  20. "create_time": ['year', 'month', 'day', 'week_day', 'gt', 'gte', 'lt', 'lte', 'range'],
  21. "update_time": ['year', 'month', 'day', 'week_day', 'gt', 'gte', 'lt', 'lte', 'range']
  22. }