horrible_nerd
horrible_nerd

Reputation: 125

use of viewsets in django rest framework

Being new to django rest framework , I often get puzzled as what exactly is the use of viewset when we can overwrite crud methods in serializers too .Another thing is that how is overwriting crud methods in serializers different from overwriting crud methods in viewsets ?

Upvotes: 0

Views: 105

Answers (1)

Vsevolod Timchenko
Vsevolod Timchenko

Reputation: 756

Technically, you can overwrite whatever you like wherever you like. The whole thing is just a convention.

The main idea is separation of concerns.

When you overwrite your views it's for the purpose of pre-processing the incoming request.

When you overwrite your serializers - it's because you want to change how the incoming data is serialized to be stored in your system (or how it is deserialized to be shown to the front-end).

Upvotes: 1

Related Questions