user13266902
user13266902

Reputation:

HTTP methods for the Django Rest Framework Viewset

I'm working on django rest framework viewset and want to know which HTTP methods map to the functions:

1.list()

2.create()

3.retrieve()

4.update()

5.partial_update()

6.destroy()

I have searched a lot but I didn't got the specific answer to my question.

So I just want to know which http method maps all the above listed functions

thanks in advance!!

Upvotes: 2

Views: 1388

Answers (2)

Prateek Gupta
Prateek Gupta

Reputation: 2770

In simple way you can say:

1.list(): HTTP Get

2.create(): HTTP Post

3.retrieve(): HTTP Get

4.update(): HTTP Put

5.partial_update(): HTTP Patch

6.destroy(): HTTP Delete

Upvotes: 5

Yevhenii M.
Yevhenii M.

Reputation: 827

You can see Django Rest Framework code and see in routers.py file methods mapping, e.g. in SimpleRouter:

  • GET: list() and retrieve()
  • POST: create()
  • PUT: update()
  • PATCH: partial_update()
  • DELETE: destroy()

Upvotes: 7

Related Questions