Django's class based views are a welcome departure from the old-style views.
Views
REST framework provides a simple APIView class, built on Django's django.generics.views.View. The APIView class ensures five main things:
- Any requests inside the view will become
Requestinstances. Requestinstances will have theirrenderersandauthenticationattributes automatically set.Responseinstances will have theirparsersandserializerattributes automatically set.APIExceptionexceptions will be caught and return appropriate responses.- Any permissions provided will be checked prior to passing the request to a handler method.
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.
APIView
Method handlers
Describe that APIView handles regular .get(), .post(), .put(), .delete() etc...