We are building a website for several tenants, and some tenants want different URLs, etc. There is no big deal, and this is what we have already fixed by creating several urls.py that can serve ROOT_URLCONF. When it comes to the request, we simply use our middleware that installs request.urlconf. So far so good.
But we also use celery for a bunch of nightly tasks, and one of them sends emails. Here we do not have request(obviously), so we cannot use this to switch ROOT_URLCONFin this way. But the change django.conf.settings.ROOT_URLCONFdoes not work either (which is logical). Is there a way to switch URLConf, which uses the "middle process"?
Actually, it’s not possible to run multiple instances of Celery, each with its own settings, because not all objects can be effectively connected to the tenant to which they belong (the types are different, we start with Userwho the tenant knows).
source
share