0

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.

Valeriu
  • 11
  • 6

1 Answers1

0

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."

Noob
  • 11
  • 1
  • 4
  • Thanks, Noob! That's exactly what I did and it (kind of) solved the issue. Kind of in the sense that I can set tasks and schedules on the public schema to have effect on the tenant schemas, which still achieves what I wanted to do. But when I set a task on the tenant schema, nothing happens. – Valeriu Jul 07 '23 at 06:05
  • If you are adding data to the tenant table, make sure you run the worker with the corresponding tenant domain, such as org1.localhost. This will insert the data into the org1 schema. If you use the public schema, it will not work and the data will be inserted into the public schema tables. or if you are facing different pls let me know. – Noob Jul 07 '23 at 09:21
  • Thanks! But how do I make sure to run the worker with the corresponding tenant domain? Where do I set this? – Valeriu Jul 10 '23 at 08:06