def __call__(self, request): set_tenant_schema_for_request(request) response = self.get_response(request) return response
def destroy(self, request, *args, **kwargs): set_tenant_schema_for_request(self.request) surgery = Surgery.objects.get(pk=self.kwargs["pk"]) return super().destroy(request, *args, **kwargs)
def save_model(self, request, obj, form, change): set_tenant_schema_for_request(request) tenant = tenant_from_request(request) obj.tenant = tenant super().save_model(request, obj, form, change)
def get_queryset(self): set_tenant_schema_for_request(self.request) tenant = tenant_from_request(self.request) return super().get_queryset().filter(tenant=tenant)
def get_queryset(self, request, *args, **kwargs): set_tenant_schema_for_request(request) queryset = super().get_queryset(request, *args, **kwargs) tenant = tenant_from_request(request) queryset = queryset.filter(tenant=tenant) return queryset