在django-tastypie中返回POST上的数据 [英] Returning data on POST in django-tastypie

查看:97
本文介绍了在django-tastypie中返回POST上的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这是一个对象创建函数返回新创建的对象的标准。

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

所以,任何想法你怎么做这个在tastypie?当我发送POST请求时,对象被创建,我没有得到任何回应。我想要的是接收新创建的对象(或至少是PK)的JSON表单。

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).

我尝试覆盖脱水方法,但是在POST方面似乎没有被调用。

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

任何想法?

推荐答案

不能相信答案是很容易。

Can't believe the answer was so easy.

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

只需添加 always_return_data = True 到您的

这篇关于在django-tastypie中返回POST上的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆