4👍
✅
class getAllStores(generics.ListAPIView,APIView):
"""
Provides access to all orders within the system.
"""
model = stores # Model name
serializer_class = getAllStoresDetailSerializer # Call serializer
def get_queryset(self):
return stores.objects.filter()
Serializer:
class getAllStoresDetailSerializer(serializers.ModelSerializer):
storeTags = serializers.Field(source='StoreTags')
storeImage = serializers.Field(source='storeImage')
class Meta:
model = stores
fields = ('storeName','storeDescription',
'storeURL','storePopularityNumber','storeImage','storeTags',
'storeSlug','createdAt','updatedAt','StoreCoupons'
)
I think you have to modify the storeImage method in order to provide the path of the image on the server……or define new method for this ….
3👍
You need to return a Response
, rather than just returning a list.
ret = [i.storeName for i in stores.objects.all()]
return Response(ret)
Source:stackexchange.com