I am developing a Django backend application with Django Rest Framework. Apart from having to write a lot of code, is it good practice to have a separate endpoint for each CRUD operation? Say I have an Organization model that I would like to create CRUD endpoints for. My usual approach is to create an endpoint ListCreateOrganization(generics.ListCreateAPIView) and map that to the path /organization/. Then create another endpoint /organization/<int:pk>/ for a RetrieveUpdateDeleteOrganization(generics.RetrieveUpdateDestroyAPIView) (assuming all CRUD operations apply). What are the scalability and performance concerns of this approach? What about creating five endpoints and mapping that to each operation:
- Create -
/organization/create - List (get multiple instances) -
/organization/list/ - Get a single instance -
/organization/<int:pk>/retrieve/ - Update a single instance -
/organization/<int:pk>/update/ - Delete a single instance -
/organization/<int:pk>/delete/
Aucun commentaire:
Enregistrer un commentaire