[Django]-Is it better to use GenericAPIView or basic APIView while writing class based views (CBV) with Django Rest Framework (DRF)

2👍

Personaly I prefer use GenericAPIViews and the suitables mixins, is more verbose but I have more control over the REST action added, and I think it help to others developer that work with my projects.

For manage the rest documentation, you can use drf-yasg that allow tell the serializer for each method.

0👍

i will not suggest the GenericAPIView because, suppose you have an API for get method only and you are using GenericAPIView, it will unnecessary show lots of methods(get/put/delete/post) whereas you need only get. so that case i ll suggest you to use anyone among UpdateAPIView, RetrieveAPIView, ListAPIView, CreateAPIView according to your need

Leave a comment