Django Rest Framework API #14 / Override Create Action | CREATE Method ModelViewSet.

preview_player
Показать описание
How to override (CREATE) action inside django rest framework ModelViewSet /ModelSerializer Create Method
.
How to read the data that was sent through a post request using (request) argument then create an object and save it in the database.

Override Delete Action (destroy method) DELETE Request:

ModelViewset With Serializer and Router:
Рекомендации по теме
Комментарии
Автор

we can do this in much more simple way

def create(self, request, *args, **kwargs):
serializer =
if serializer.is_valid():
serializer.save()
return Response(serializer.data)


Hope this helps. Thanks for tutorials

midhunskani
Автор

Great and very helpful video, I’m looking forward for more.

stevesteve
Автор

tnx.
super great BUT if you have an model serializer, use it to validate and save data that you got from request !

anton-r
Автор

Thanks for the video, it helped me :)

francois-xaviercao
Автор

Thank you, this video helped me in my project

think-dotest
Автор

hey
first of all your videos are great to understand how a django api works.
I've been following and executing the django api for car specs till this video and i cannot move forward because i'm facing an issue i.e. when i put depth =1, the field on the running server does not appear and when i dont put any depth, the field appears and i select one of the options for my entries and perform POST but when i GET the entry values, the car_plan field is null always, it doesnt change no matter what i do.
Please help me clear this so that i can move on to the next stages

anishghosh
Автор

Does it matter much whether we override perform_create or create function? Thx.

dodokwak
Автор

why in create method Id always extra increment example: if id was 4 now when we send POST requ. new data Id will be 6 .

vaibhavsaxena
Автор

It says 'user' for doing the same thing above. Can you please tell me what is the problem??

sarojpaudel
join shbcf.ru