I'm using django-tastypie to make resources for models.
Can you help tell me how to cache dehydrate method of my ArtistResource? And what extra django settings should i provide to use cache?
Thanks very much. I've never used cache before, so i'm discouraged about this.
class ArtistResource(DehydrateImageMixin, SearchableResource):
class Meta:
filtering = {
"id": ALL_WITH_RELATIONS,
}
queryset = Artist.objects.all()
resource_name = 'artist'
allowed_methods = ['get']
def dehydrate(self, bundle):
bundle = super(ArtistResource, self).dehydrate(bundle)
count_tracks = bundle.obj.audio_tracks.count()
bundle.data['count_tracks'] = ungettext(
'%(count)d %(track)s', '%(count)d %(track)s', count_tracks
) % {'count': count_tracks, 'track': 'track'}
return bundle