user12616937
user12616937

Reputation:

Delete operation using Serializes

In official document serializers class show only create & update method only. There is any way to perform delete method? is say Yes how? if say No why?

Upvotes: 1

Views: 6153

Answers (1)

MarkL
MarkL

Reputation: 353

Here is the source code of serializer. https://github.com/encode/django-rest-framework/blob/master/rest_framework/serializers.py

As you can see there is no delete. I think the reason is because there is nothing to serialize/deserialze when you make a deletion request.

Think about the what it means by serialization and deserialization. It's a process of turning object in memory to a string representation (or the other way around). When we make a request to delete /Foo/5, there's no string representation nothing to deserialize.

If you want custom behavior during deletion you can override delete() in viewset.

Upvotes: 2

Related Questions