Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returning data on POST in django-tastypie

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?

like image 718
mhaligowski Avatar asked Apr 13 '12 09:04

mhaligowski


1 Answers

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.

like image 53
mhaligowski Avatar answered Sep 22 '22 22:09

mhaligowski