How to make django-tenants work with django-q

163 views Asked by At

Django newbie here. I'm trying to make django-q work with django-tenants.

I am getting this error:

13:38:41 [Q] ERROR relation "django_q_schedule" does not exist
LINE 1: ...edule"."task", "django_q_schedule"."cluster" FROM "django_q_...
                                                         ^

I assume that the issue is that django-q looks at the public schema and doesn't find the task and schedule table.

Settings.py:

SHARED_APPS = (
'django_tenants',  # mandatory
'companies', # you must list the app where your tenant model resides in
'accounts.apps.AccountsConfig',
'django.contrib.humanize',

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

)

TENANT_APPS = (
# your tenant-specific apps
'django_q',
'loads',
'dispatchers',
'accounts.apps.AccountsConfig',

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

INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS]

I also tried following django-tenants-q instructions, but the python3 manage.py mscluster command does not work.

1

There are 1 answers

3
Noob On

The error you are facing indicates that your shared app is using Django-Q, but you added it in the tenant app. This means that shared apps will not have access to Django-Q.

Try adding Django-Q to both the shared and tenant tuple, as it might resolve the issue."