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',)
标签:功能,UserSerialiser,viewsets,rest,framework,backends,搜索,import,drf 来源: https://www.cnblogs.com/tangda/p/11908998.html