Django's class based views are a welcome departure from the old-style views.
REST framework provides a simple APIView
class, built on Django's django.generics.views.View
. The APIView
class ensures five main things:
Request
instances.Request
instances will have their renderers
and authentication
attributes automatically set. Response
instances will have their parsers
and serializer
attributes automatically set.APIException
exceptions will be caught and return appropriate responses.Additionally there are a some minor extras, such as providing a default options
handler, setting some common headers on the response prior to return, and providing the useful initial()
and final()
hooks.
Describe that APIView handles regular .get(), .post(), .put(), .delete() etc...