Skip to main content

Multi-tenancy on Django using PostgreSQL schemas.

Project description

Packaging: poetry Code style: black Build status Documentation status Code coverage PyPi version Downloads

This app uses PostgreSQL schemas to support data multi-tenancy in a single Django project. It is a fork of django-tenants with some conceptual changes:

  • There are static tenants and dynamic tenants. Static tenants can have their own apps and urlconf.

  • Tenants can be simultaneously routed via subdomain and via subfolder on shared subdomain.

  • Public is no longer the schema for storing the main site data. Public should be used only for true shared data across all tenants. Table “overriding” via search path is no longer encouraged.

  • Management commands can be run on multiple schemas via wildcards - the multiproc behavior of migrations was extended to just any tenant command.

Which package to use?

There are currently multiple packages to handle multi-tenancy via PostgreSQL schemas. This table should help you make an informed decision on which one to choose.

Package

Features

django-tenant-schemas

Original project. Active and maintained by @goodtune.

django-tenants

Active and maintained by @tomturner. Built on top of django-tenant-schemas. Uses a Domain model for allowing multiple domains per tenant. Allows for parallel migrations with custom migration executor. Other multiple improvements.

django-pgschemas

Active and maintained by @lorinkoz. Built on top of django-tenants. Different philosphy for tenants. Other improvements listed above.

Documentation

https://django-pgschemas.readthedocs.io/

Breaking changes

v0.9.0

  • Dropped support for Python < 3.8, Django < 3.1.

v0.7.0

  • Changed public API for getting/setting active schema. Public API is now get_current_schema, activate(schema), activate_public(). Any schema descriptor can still be used as context manager.

  • Changed location of tenant model and domain model in settings. TENANT_MODEL and DOMAIN_MODEL keys are now under TENANTS["default"] instead of TENANTS["public"]. This is required for future static-tenant-only configurations.

  • Module cache renamed to contrib.cache.

  • Module contrib.channels renamed to contrib.channels2.

  • Added module contrib.channels3.

  • Management command option --executor {sequential, parallel} renamed to --parallel.

  • All signals renamed. Added schema_activate signal.

Contributing

  • Join the discussion at https://github.com/lorinkoz/django-pgschemas/discussions.

  • PRs are welcome! If you have questions or comments, please use the link above.

  • To run the test suite run make or make coverage. The tests for this project live inside a small django project called dpgs_sandbox. Database password and database host can be set through the environment variables DATABASE_PASSWORD and DATABASE_HOST.

Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-pgschemas-0.9.0.tar.gz (36.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_pgschemas-0.9.0-py3-none-any.whl (47.2 kB view details)

Uploaded Python 3

File details

Details for the file django-pgschemas-0.9.0.tar.gz.

File metadata

  • Download URL: django-pgschemas-0.9.0.tar.gz
  • Upload date:
  • Size: 36.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for django-pgschemas-0.9.0.tar.gz
Algorithm Hash digest
SHA256 4d8400793909f62c92e6e2f55516698309a19b140c82731b26fd7412d4ac7ce9
MD5 d4491ad849264339532ab23a0e3cea02
BLAKE2b-256 c5ce597e07bcc5ddd4be343f7c6c8c708d2f7437d975ce8c63830e7ef960a3e9

See more details on using hashes here.

File details

Details for the file django_pgschemas-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: django_pgschemas-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for django_pgschemas-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f375479ae21487e906c2bbf226413391b025fef8dd16c0c4659e7b9c28066a40
MD5 fdf80f62ea7a95a7b70e2e710009a51e
BLAKE2b-256 3984ade3722176dea73a2f013ab7c8a04b740f3f6c99af08a5d3badbaddff006

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page