Reputation: 5076
How can I add custom fields (in this case, meta codes) to a dispatch_list
in Tastypie?
Upvotes: 0
Views: 893
Reputation: 8995
a better approach IMHO would be to use the function made to override/add fields to the data before making the response:
def alter_list_data_to_serialize(self, request, data):
data['meta']['current_time'] = datetime.strftime(datetime.utcnow(), "%Y/%m/%d")
return data
Upvotes: 5
Reputation: 2163
You can add a new field to the resource and dehydrate it with dehydrate_field_name().
Upvotes: 1