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?
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