Lets suppose that I have tenant A and B, if I call the get_example endpoint with the tenant A I get the right data (tenant A data), but when I make a second request to same endpoint with tenant B I get the tenant A data.
If I refresh the server and do the same excersice in the reverse order (first tenant B and then tenand A) it happens again but returning tenant B data.
It happens with the queryset definition queryset = MyModel.objects.all() in the viewset, but if I call it again in the endpoint (like p2 in the example) it works fine.
class MyModelViewSet(ModelViewSet):
queryset = MyModel.objects.all()
serializer_class = MyModelSerializer
@action(detail=False)
def get_example(self,request):
p1=self.queryset[0]
p2=MyModel.objects.all()[0]
print(p1, p2)
data = MyModelSerializer(self.queryset, many = True).data
return Response(data)
Lets suppose that I have tenant A and B, if I call the
get_exampleendpoint with the tenant A I get the right data (tenant A data), but when I make a second request to same endpoint with tenant B I get the tenant A data.If I refresh the server and do the same excersice in the reverse order (first tenant B and then tenand A) it happens again but returning tenant B data.
It happens with the queryset definition
queryset = MyModel.objects.all()in the viewset, but if I call it again in the endpoint (likep2in the example) it works fine.