feat: goal增加查询条件
This commit is contained in:
parent
67d04a9a41
commit
8ab973749d
|
@ -0,0 +1,13 @@
|
|||
from django_filters import rest_framework as filters
|
||||
from apps.mtm.models import Goal
|
||||
|
||||
class GoalFilter(filters.FilterSet):
|
||||
class Meta:
|
||||
model = Goal
|
||||
fields = {
|
||||
"mgroup": ["exact", "in"],
|
||||
"mgroup__name": ["exact", "in"],
|
||||
"goal_cate": ["exact", "in"],
|
||||
"goal_cate__code": ["exact", "in"],
|
||||
"year": ["exact"]
|
||||
}
|
|
@ -4,6 +4,7 @@ from rest_framework.mixins import ListModelMixin
|
|||
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
|
||||
from apps.mtm.models import Material, Mgroup, Shift, Team, Goal
|
||||
from apps.mtm.serializers import MaterialSerializer, MgroupSerializer, ShiftSerializer, TeamSerializer, GoalSerializer
|
||||
from apps.mtm.filters import GoalFilter
|
||||
|
||||
# Create your views here.
|
||||
class MaterialViewSet(CustomModelViewSet):
|
||||
|
@ -67,5 +68,5 @@ class GoalViewSet(CustomModelViewSet):
|
|||
queryset = Goal.objects.all()
|
||||
serializer_class = GoalSerializer
|
||||
select_related_fields = ['mgroup', 'goal_cate']
|
||||
filterset_fields = ['mgroup', 'goal_cate', 'year', 'goal_cate__code']
|
||||
filterset_class = GoalFilter
|
||||
search_fields = ['name']
|
Loading…
Reference in New Issue