I leave you two more links that may be interesting

https://stackoverflow.com/questions/41094013/when-to-use-serializers-create-and-modelviewsets-create-perform-create
https://github.com/repleo/bounca/blob/master/bounca/api/mixins.py

El jue., 16 ene. 2020 a las 2:30, Yiran Hu (<med...@gmail.com>) escribió:

> Yes that makes sense!
>
> On Wednesday, January 15, 2020 at 7:57:45 AM UTC-5, Jason wrote:
>>
>> `create` is the direct handler for any POST requests that come in.  So,
>> it needs to have `request` in there, because its a subclass of
>> `django.views.generic.View`  View handlers need to implement the parameter
>> contract that Django specifes. This is hit after all post-request
>> middleware has executed, which is the period between when the URL handler
>> recieves the request and the view handler gets it.
>>
>> perform_create is a helper method in the DRF API.  As you can see in the 
>> CreateAPIView
>> definition
>> <http://www.cdrf.co/3.9/rest_framework.generics/CreateAPIView.html#create>,
>> it processes the serializer and then passes it to the view's create method.
>>
>> Therefore, if you so desire, you can have additional logic in the view
>> create process without overriding the entirity of create.  All you need to
>> do is re-implement perform_create, which takes in the serializer data, but
>> has everything associated with the request in the `self` parameter
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-rest-framework+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-rest-framework/e66f30c2-3164-432c-99b8-ef73ca4d01ce%40googlegroups.com
> <https://groups.google.com/d/msgid/django-rest-framework/e66f30c2-3164-432c-99b8-ef73ca4d01ce%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
--------
Gonzalo Amadio

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/CANyTv7of1Y%3DL4cqyQfvT22nq4Eg_buNq7QaCV9_BFhUdKM9r5w%40mail.gmail.com.

Reply via email to