CreateModelMixin sends everything back to the user

43 views
Skip to first unread message

Kai Schlamp

unread,
May 19, 2013, 10:18:42 AM5/19/13
to django-res...@googlegroups.com
Hello together.

I just found out that the "create" method of "CreateModelMixin" sends everything back to the client after the instance was created. Why is this the default? It seems to me that it just bloats the network traffic, especially if the user submitted a lot of data. What do you recommend to turn this off? Overwrite the "create" method or the "data" method of the serializer?

Best regards,
Kai

Tom Christie

unread,
May 19, 2013, 11:28:45 AM5/19/13
to django-res...@googlegroups.com
Hi Kai,

  Returning the object is conventional.  Note that there might also be read-only attributes on the object, that the client isn't able to determine until after the object has been returned to it.
  If you wanted to override this then yes, override `.create`, either in a new base class that you use throughout, or by explicitly adding it to each view, eg. perhaps using a mixin class.

Cheers,

  Tom



--
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-fram...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages