|
|
|
from django.shortcuts import render
|
|
|
|
|
|
|
|
# Create your views here.
|
|
|
|
from rest_framework import viewsets
|
|
|
|
from django_filters.rest_framework import DjangoFilterBackend
|
|
|
|
from app.models import TP
|
|
|
|
from app.serializers import SerialMyModel
|
|
|
|
from app.pagination import MyPageNumberPagination
|
|
|
|
|
|
|
|
|
|
|
|
class ModelQuery(viewsets.ModelViewSet):
|
|
|
|
# 查询类
|
|
|
|
queryset = TP.objects.all().order_by("uid")
|
|
|
|
# 序列化类
|
|
|
|
serializer_class = SerialMyModel
|
|
|
|
# 分页类
|
|
|
|
pagination_class = MyPageNumberPagination
|
|
|
|
|
|
|
|
# 条件筛选
|
|
|
|
filter_backends = [DjangoFilterBackend]
|
|
|
|
filterset_fields = ('police_id',)
|