标签:code 例子 view field student ram pre ons work
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(排除返回的字段))
标签:code 例子 view field student ram pre ons work
原文地址:https://www.cnblogs.com/weiweivip666/p/14628258.html