Monday, October 12, 2020

DRF fetching issue with one to many relational data.

I don't get images in items objects. What mistake I have done, please me to find out.

class RequestedItemImageSerializers(serializers.ModelSerializer):
        class Meta:
        model = RequestedItemImage
        fields = ['image']


class RequestedItemSerializers(serializers.ModelSerializer):
images = RequestedItemImageSerializers(read_only=True, many=True)
country = CountrySerializers(read_only=True)
           class Meta:
            model = RequestedItem
           fields = ['title', 'description', 'quantity', 'price', 'images', 'country']

items = RequestedItem.objects.all()
serializer = RequestedItemSerializers(items, many=True)
data = {
   'items': serializer.data,
}



Regards
Habib

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4b47f056-ab43-4f25-af87-4e74db1017a6n%40googlegroups.com.

No comments:

Post a Comment