bernardopires / django-tenant-schemas

Tenant support for Django using PostgreSQL schemas.
https://django-tenant-schemas.readthedocs.org/en/latest/
MIT License
1.45k stars 425 forks source link

django-tenants TypeError: argument of type 'TenantQueryset' is not iterable #672

Closed hunar-art closed 2 years ago

hunar-art commented 2 years ago

i've made a system for hotels , i want to give it to several hotels with the same base code , i have used django-tenant-schemas and this is my SHARED_APP and TENANT_APP but when i try python manage.py migrate_schemas --shared it only creates my shared apps list and when i try either manage.py migrate_schemas --tenant or manage.py migrate_schemas it raise this error

if public_schema_name in tenants: TypeError: argument of type 'TenantQueryset' is not iterable

this is my settings.py

SHARED_APPS = [
    'tenant_schemas',
    'users',
    'rosetta',
    'widget_tweaks',
    'import_export',

    'django.contrib.contenttypes',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

TENANT_APPS = [
    'rooms',
    'vistors',
    'booking',
    'costs',
    'payments',
    'cancel',
]

INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS]
TENANT_MODEL= "rooms.Hotel"

#db engine 
'ENGINE': 'tenant_schemas.postgresql_backend',

my models.py

class Hotel(TenantMixin):
    hotel_name = models.CharField(max_length=40,unique=True)
    def __str__(self):
        return self.hotel_name

class Room(models.Model):
    room_no = models.IntegerField()
    #others 

and i have more models but all of them inherited from models.Model ,in the public schema it only created tables for SHARED_APP apps , TENANT_APP not created django version 2.2 db : postgresql is there something else i have to change or is'nt there another way to achieve that please