from django.db.models import Manager
from model_tenants.helpers.tenants import get_current_tenant


class SingleTenantModelManager(Manager):

    def get_queryset(self):
        tenant = get_current_tenant()
        if tenant:
            return super().get_queryset().filter(tenant=tenant)
        else:
            raise TenantNotFoundError()

    def create(self, *args, **kwargs):
        tenant = get_current_tenant()
        if tenant:
            return super().get_queryset().filter(tenant=tenant)
        else:
            raise TenantNotFoundError()


class MultipleTenantModelManager(Manager):

    def get_queryset(self):
        tenant = get_current_tenant()
        if tenant:
            return super().get_queryset().filter(tenants=tenant)
        else:
            raise TenantNotFoundError()

    def create(self, *args, **kwargs):
        tenant = get_current_tenant()
        if tenant:
            return super().get_queryset().filter(tenants=tenant)
        else:
            raise TenantNotFoundError()

@@ -30,16 +30,51 @@
 Manager%0A
+from django.db import transactions%0A
 from mod
@@ -486,58 +486,83 @@
     
-return super().get_queryset().filter(tenant=tenant
+kwargs%5B'tenant'%5D = tenant%0A            return super().create(*args, **kwargs
 )%0A  
@@ -976,53 +976,144 @@
     
-return super().get_queryset().filter(
+with transactions.atomic():%0A                model_instance = super().create(*args, **kwargs)%0A                model_instance.
 tenants
-=
+.add(
 tena
@@ -1149,29 +1149,28 @@
  raise TenantNotFoundError()
-%0A

fix create method in managers