Home > Software engineering >  Django Rest Framework CRUD
Django Rest Framework CRUD

Time:06-05

I´m building an API with Django Rest Framework, and I’m wondering if it's enough to use only the ModelViewSet class to implement the CRUD. My worries is that it’s not enough for the frontend to consume and use the create, read, update and delete functionalities.

CodePudding user response:

For a short answer, "yes".

But, I would suggest you to read the official docs from DRF.

ModelViewSet's docs

The ModelViewSet class inherits from GenericAPIView and includes implementations for various actions, by mixing in the behavior of the various mixin classes.

The actions provided by the ModelViewSet class are .list(), .retrieve(), .create(), .update(), .partial_update(), and .destroy().

GenericAPIView's docs

This class extends REST framework's APIView class, adding commonly required behavior for standard list and detail views.

Each of the concrete generic views provided is built by combining GenericAPIView, with one or more mixin classes.

--

There are also plenty of blogs explaining why and when to use these class.

Django Rest Framework ViewSets

--

Lastly, I'm new to the community just like you did. I'm not sure this kind of question would be allowed here or not. But, what I'm trying to say is..

Stop worrying, just go and try out yourself. I believe that people in the community would willing to help you out if you've stuck.

  • Related