Django rest API crud example with unit testing

Hemanth S P
Django lions ✨
Published in
2 min readFeb 3, 2021

--

Hi, in this article I am going to show you what are the different ways of creating crud in the Django rest framework with the unit testing.

Django rest crud example API with unit testing
Photo by Nick Fewings on Unsplash
  1. Function-based crud
  2. class-based API view crud
  3. Generic class-based view crud
  4. Generic class-based view with views router crud
  5. Viewset crud
  6. ModelViewset crud

1. Function-based crud

as above shows everything is simple and line by line and two URLs added at the bottom for unit case check GitHub repo.

2. class-based API view crud

Class-based API views inhered from view class so it has GET, POST, etc.. methods

--

--