from django.shortcuts import render from apps.enm.models import Mpoint, MpLog from apps.utils.viewsets import CustomModelViewSet, CustomGenericViewSet from rest_framework.mixins import ListModelMixin from apps.enm.serializers import (MpointSerializer, MpLogSerializer) class MpointViewSet(CustomModelViewSet): """ list:测点 测点 """ queryset = Mpoint.objects.all() serializer_class = MpointSerializer select_related_fields = ['create_by', 'belong_dept', 'ep_monitored', 'ep_belong', 'mgroup'] filterset_fields = ['belong_dept', 'ep_monitored', 'ep_belong', 'mgroup'] search_fields = ['number', 'code'] class MpLogViewSet(ListModelMixin, CustomGenericViewSet): """ list:测点原始记录 测点原始记录 """ queryset = MpLog.objects.all() serializer_class = MpLogSerializer select_related_fields = ['mpoint'] filterset_fields = ['mpoint']