[Answer]-How to reference to a thumb attribute in tastypie resource foreign key?

1👍

well I finally get it works here is what I did:

class AlbumResource(ModelResource):
    cover_img = fields.ForeignKey('album.api.ImageResource','cover_img')


class Meta:
    always_return_data=True

    queryset = Album.objects.all()
    resource_name = 'album'
    authorization = AlbumAuthorization()

def dehydrate(self, bundle):
    im = get_thumbnail(bundle.obj.cover_img.src, '200x200', quality=90)
    bundle.data['cover_thumb'] = im.url
    return bundle

Leave a comment