Returning data on POST in django-tastypie

≯℡__Kan透↙ 提交于 2019-11-29 01:47:01

问题


I consider it a standard that an object-creating function returns the newly created object.

So, any idea how do you do that in tastypie? When I send the POST request, the object is created, I get nothing in response, though. What I would like is to receive the JSON form of the newly created object (or at least the PK).

I tried overriding the dehydrate method, but it seems that it's not even called when it comes to POST.

Any ideas?


回答1:


Can't believe the answer was so easy.

http://django-tastypie.readthedocs.org/en/latest/resources.html#always-return-data

Just add always_return_data = True to your Meta.



来源:https://stackoverflow.com/questions/10138169/returning-data-on-post-in-django-tastypie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!