例子
from rest_framework.views import APIView
class StudentAPIView(APIView):
def get(self, request):
pk = request.query_params.get(pk)
student_obj = Student.objects.get(pk)
return Response(model_to_dict(student_obj))
# model_to_dict中的参数
model_to_dict(模型对象, fields(指定返回的字段), exclude(排除返回的字段))