i don't know whats wrong with this code, previously i was getting assertion error and now this
class OrganisationSerializer(ModelSerializer):
products = ProductSerializer(many=True) #manytomany field
pictures = PicturesSerializer(source ='pictures_set',many=True) #foreign key field
class Meta:
model = Organisation
fields = ['name','address' ,'products','pictures']
@api_view(['GET'])
def get_data(request):
data = None
query_set = Organisation.objects.all()
serialized_data = OrganisationSerializer(data = query_set,many =True)
if serialized_data.is_valid():
data = serialized_data.data
print(data)
return Response(data,status=status.HTTP_200_OK)
problem
returning no data
OrganisationSerializeris not valid, but that should always be the case, since you did not bound it with request data.