Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

queryset = Model.objects.all() not working using django_tenants #102

Open
alejandro-sisteya opened this issue Jun 15, 2023 · 1 comment
Open

Comments

@alejandro-sisteya
Copy link

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)
@diegooquendoopalytica
Copy link

I also experienced this problem and it is just as @alejandro-sisteya defines it; On the first call to the endpoint p1 = p2, but on the second call p1 != p2.

I would think that @alejandro-sisteya and I have the same architecture in our backend; Django with DRF. In my particular case I am deploying the server on AWS Lambda with Zappa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants