Returning data on POST in django-tastypie

mhaligowski picture mhaligowski · Apr 13, 2012 · Viewed 8.7k times · Source

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?

Answer

mhaligowski picture mhaligowski · Apr 13, 2012

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.