aroooo
aroooo

Reputation: 5076

Tastypie: Add meta codes to dispatch_list

How can I add custom fields (in this case, meta codes) to a dispatch_list in Tastypie?

Upvotes: 0

Views: 893

Answers (2)

Hassek
Hassek

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

Nam Ngo
Nam Ngo

Reputation: 2163

You can add a new field to the resource and dehydrate it with dehydrate_field_name().

Upvotes: 1

Related Questions