Skip to content

Instantly share code, notes, and snippets.

@carvalhochris
Created February 7, 2023 16:16
Show Gist options
  • Select an option

  • Save carvalhochris/31956e573264bb019f05846c21685dac to your computer and use it in GitHub Desktop.

Select an option

Save carvalhochris/31956e573264bb019f05846c21685dac to your computer and use it in GitHub Desktop.
The Card links to a thumbnail
class CardSerializer(serializers.ModelSerializer):
title = serializers.CharField()
song = SongSerializer(read_only=True)
thumbnail = HyperlinkedSorlImageField(
'300x300',
options={"crop": "center"},
source='image',
read_only=True
)
class Meta:
model = Card
fields = ['id', 'title', 'link', 'image', 'song',
'thumbnail', 'desc', 'is_paid', 'price']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment