feat: Add Image URL to API
This commit is contained in:
@@ -3,6 +3,12 @@ from rest_framework import serializers
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
|
|
||||||
|
class ImageSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Image
|
||||||
|
fields = ['id', 'image']
|
||||||
|
|
||||||
|
|
||||||
class AdoptionNoticeSerializer(serializers.HyperlinkedModelSerializer):
|
class AdoptionNoticeSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
location = serializers.PrimaryKeyRelatedField(
|
location = serializers.PrimaryKeyRelatedField(
|
||||||
queryset=Location.objects.all(),
|
queryset=Location.objects.all(),
|
||||||
@@ -21,11 +27,7 @@ class AdoptionNoticeSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
allow_null=True
|
allow_null=True
|
||||||
)
|
)
|
||||||
|
|
||||||
photos = serializers.PrimaryKeyRelatedField(
|
photos = ImageSerializer(many=True, read_only=True)
|
||||||
queryset=Image.objects.all(),
|
|
||||||
many=True,
|
|
||||||
required=False
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = AdoptionNotice
|
model = AdoptionNotice
|
||||||
|
Reference in New Issue
Block a user