The docs on their GitHub page suggests that what I'm trying to do should work:
thumb_url = profile.photo['avatar'].url
In my project, it gives an error:
THUMBNAIL_ALIASES = {
'': {
'thumb': {'size': (64, 64), 'upscale': False},
},
}
class Image(models.Model):
place = models.ForeignKey(Place, models.CASCADE, 'images')
image = ThumbnailerImageField(upload_to='')
class ImageSerializer(serializers.Serializer):
image = serializers.ImageField()
thumb = serializers.ImageField(source='image.image["thumb"].url')
AttributeError: Got AttributeError when attempting to get a value for field `thumb` on serializer `ImageSerializer`.
The serializer field might be named incorrectly and not match any attribute or key on the `Image` instance.
Original exception text was: 'ThumbnailerImageFieldFile' object has no attribute 'image["thumb"]'.
The url of image
is serialized properly if thumb
is removed. How can I get DRF to serialize the url of the thumbnail?
settings.py
api/serializers.py
using