Registry / database / tenant-schemas-celery

tenant-schemas-celery

JSON →
library4.0.3pypypiunverified

Celery integration for django-tenant-schemas and django-tenants. Automatically sets the schema on Celery task invocations so that tasks run in the correct tenant context. Current version is 4.0.3, supporting Python >=3.9. Release cadence is irregular, with major versions aligned with Django or Celery breaking changes.

pip install tenant-schemas-celery
INSTALL
IMPORT
SIG · TENANT-SCHEMAS-CEL
T
tenant-schemas-celery
databasepythonv4.0.3
Install
3.6s avg
Import
Disk
38MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 40.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.6s · import 0.000s · 41MB
38MB installed
● package 38MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CeleryApp
from tenant_schemas_celery import CeleryApp
from tenant_schemas_celery.app import CeleryApp

Create a Celery app instance that automatically manages tenant schema context. Replace 'your_project' with your Django project name.

import os os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'your_project.settings') from tenant_schemas_celery.app import CeleryApp app = CeleryApp('your_project') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks()
Debug
Known issues
breakingVersion 4.0.0 dropped support for django-tenant-schemas (legacy) and Python <3.9. If you need the old package, pin to <4.0.0.
fix
Upgrade to 4.0.0+ and use django-tenants instead of django-tenant-schemas.
affects: <4.0.0
breakingVersion 3.0.0 introduced a custom task class via CeleryApp overriding the default Task class. If you have custom task base classes, they may not be applied unless you set the Task class explicitly.
fix
Use app.Task to inherit tenant schema support in custom tasks, or set app.Task = YourCustomTask in CeleryApp.
affects: >=3.0.0
deprecatedUsing `from tenant_schemas_celery import CeleryApp` is deprecated and will be removed. Import from the `app` submodule instead.
fix
Replace with `from tenant_schemas_celery.app import CeleryApp`.
affects: >=4.0.0
gotchaIf you use `app.send_task()`, the tenant schema is set correctly. However, tasks called via `.delay()` or `.apply_async()` from outside a tenant context (e.g., in a management command) will fail if no active schema is set.
fix
Ensure tasks are called from within a tenant context (e.g., inside a view or with `tenant_context()`) or manually set the schema.
affects: all
gotchaWhen using Celery Beat with django-celery-beat, the scheduler must be configured to use the tenant-schemas-celery scheduler to run tasks in the correct tenant context.
fix
Set `CELERY_BEAT_SCHEDULER = 'tenant_schemas_celery.schedulers.TenantAwareScheduler'` in Django settings.
affects: >=2.1.0
Upgrade
Version history
4.0.3latest on PyPI · released Aug 1, 2025
Audit
Dependencies
DjangorequiredRequired by the underlying tenant library
django-tenantsrequiredRequired for tenant context; or django-tenant-schemas (legacy)
CeleryrequiredRequired for task queue integration
Agent activity
48 hits · last 30 days
node
42
OpenAI (training)
2
Resources
tenant-schemas-celery — pip install tenant-schemas-celery · libregistry