参考:
# 安装
pip install djangorestframework
pip install django-redis
# 调试 http
#官网教程1,pip install httpie 可以用来调试http
https://blog.csdn.net/ppppfly/article/details/51086122
#官网教程2,format_suffix_patterns 使用
https://blog.csdn.net/ppppfly/article/details/51103984
request.POST # 只能处理表单(form)数据,只能处理“POST”方法.
request.data # 处理任意数据.可以处理'POST', 'PUT' 和 'PATCH'方法.
# ListCreateAPIView 使用
# 方法1
class reportInfoListView(ListCreateAPIView):
def get_queryset(self):
queryset = ReportInfo.objects.order_by("-id")[:7][::-1]
return queryset
serializer_class = ReportInfoSerializer
# 方法2
class reportInfoListView(ListCreateAPIView):
poems = ReportInfo.objects.order_by("-id")[:7][::-1]
queryset = poems
serializer_class = ReportInfoSerializer