通过APIView进入找到Request的源码


可以看见一堆属性和方法,其中request.data其实是一个方法,被包装成一个属性

继续看__getattr__和query_params方法:


代码总结:
- Request其实就是原生request对象被包装后的Request,即重写了__getattr__,return getattr(self._request, attr)
- 比如:print(request.GET)就当于print(request.query_params)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。