Say I have two models in Django – an Actor and a Movie model with many to many relationship between them. Now I’ve defined API calls for both of these models in Tastypie but when I retrieve multiple Movies in one call I would like to have included the count of the Actors in each Movie and not be required to make an additional API call for each Movie in the retrieved Movies.
Anyway to specify this in Tastypie?
Thanks!
You can add a custom count field. You need to implement dehydrate method in your resource.
Something like this should work for you:
Docs here