0

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 ?

2
  • viewsets provide the entry point into the API - the GET, PUT, PATCH, DELETE etc methods Commented Dec 29, 2019 at 20:58
  • Cool . I get that but what is the difference between the overwriting of the crud methods in serializers.py and views.py ? Commented Dec 29, 2019 at 21:10

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Can you explain this with an example ? It will make my understanding even better .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.