Wrapping API views
REST framework provides two wrappers you can use to write API views.
- The
@api_view
decorator for working with function based views. - The
APIView
class for working with class-based views.These wrappers provide a few bits of functionality such as making sure you receiveRequest
instances in your view, and adding context toResponse
objects so that content negotiation can be performed.
The wrappers also provide behaviour such as returning 405 Method Not Allowed
responses when appropriate, and handling any ParseError
exception that occurs when accessing request.data
with malformed input.
当前内容版权归 Django REST 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Django REST .