hasadna / openmuni-budgets

A web app and web API for storing, accessing, visualizing and comparing budgetary data from Israeli municipalities.
http://openmuni.org.il/
BSD 3-Clause "New" or "Revised" License
15 stars 28 forks source link

Refactor the hack in sheets.views.api.SheetItemCommentListCreate.create #335

Open ydaniv opened 10 years ago

ydaniv commented 10 years ago

Currently there's no (at least elegant) way to serialize a request with one serializer for POST (or PUT or PATCH) and return the same object serialized in it's retrieve form, i.e. using a different serializer.

So the above mentioned method override simply returns a response with an instance of a different serializer class used for read requests.

ydaniv commented 10 years ago

Can probably use the transform_ to implement that in a proper way: http://www.django-rest-framework.org/api-guide/serializers#serializing-objects