Saturday, March 02, 2013

Tastypie Cookbook — Tastypie 0.9.13-beta documentation

Tastypie Cookbook — Tastypie 0.9.13-beta documentation: "Adding Custom Values
You might encounter cases where you wish to include additional data in a response which is not obtained from a field or method on your model. You can easily extend the dehydrate() method to provide additional values:
class MyModelResource(Resource):
class Meta:
qs = MyModel.objects.all()

def dehydrate(self, bundle):
bundle.data['custom_field'] = "Whatever you want"
return bundle"

'via Blog this'