drf 搜索功能

from django_filters.rest_framework import DjangoFilterBackend

from rest_framework import viewsets

from .serializer import UserSerialiser

class UserViewset(viewsets.ReadOnlyModelViewSet):

     ''' List: 查询用户列表 Retrieve:

        查询某用户详情

        ''' queryset = user.objects.all()

         serializer_class = UserSerialiser

         filter_backends = (DjangoFilterBackend,)

         backends filter_fields = ('username',)

 

 

上一篇:Go实现简单负载均衡


下一篇:Django下使用mysql数据库