Skip to main content

Django multi-tenant app where each subdomain is a tenant

Project description

django_subdomain_tenancy CHANGELOG

django-subdomain-tenancy is a Django multi-tenant app where each subdomain is a tenant, simplifying deployment, scalability, and per-client management.

Detailed documentation is in the "docs" directory.

Quick start

1. Add django_subdomain_tenancy.apps.SubdomainConfig to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...,
        "django_subdomain_tenancy.apps.SubdomainConfig",
    ]

2. Add this configs in settings.py:

    AUTH_USER_MODEL = 'subdomain.CustomUser'
    LOGIN_URL = '/accounts/login/' 
    LOGIN_REDIRECT_URL = "/"
    LOGOUT_REDIRECT_URL = "/"

    LANGUAGE_CODE = "pt-BR" OR "en"

    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    
    EMAIL_HOST = XXXXXXXXX
    EMAIL_PORT = XXXXXXXXX
    EMAIL_USE_TLS = XXXXXXXXX
    EMAIL_HOST_USER = XXXXXXXXX
    EMAIL_HOST_PASSWORD = XXXXXXXXX
    DEFAULT_FROM_EMAIL = XXXXXXXXX

3. Include the polls URLconf in your project urls.py like this::

    path("", include("django_subdomain_tenancy.urls")),

4. Run python3 manage.py migrate to create the models.

5. Create a record in instance table for master dubdomain:

    insert into django_subdomain_tenancy_intance 
    values(1, "Master Tenant", "master", 1);

6. Create SuperUser administrator

(It needs to be this way, because they're the only user who can log in to all the subdomains.), 
and set id instance `1`:

``python3 manage.py createsuperuser``

7. Visit the / For Login in the system fronend,

`/admin/` Logging is only allowed using the master subdomain.

8. For the development environment, add one more instance; I'll use the test subdomain cobaia:

    insert into django_subdomain_tenancy_intance 
    values(2, "Cobaia Tenant", "cobaia", 1);

If use Linux or Mac add the following lines to the /etc/hosts file:

    127.0.0.1 master.localhost
    127.0.0.1 cobaia.localhost

If you're using Windows, you're starting the project the wrong way.

9. Access tenant urls:

    master.localhost:8000
    cobaia.localhost:8000

Simple Login Frontend: /accounts/login/

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_subdomain_tenancy-0.2.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

django_subdomain_tenancy-0.2.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file django_subdomain_tenancy-0.2.0.tar.gz.

File metadata

  • Download URL: django_subdomain_tenancy-0.2.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for django_subdomain_tenancy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5cf64ca53b9f751c3f16b16d82f4247359bbc2e88a80eaabef1b2a8f0b5b9246
MD5 b1d1397e6489ba965ef37eca55b6323e
BLAKE2b-256 fb8cbde3e57114c6aafc3b4256d9db05c88c4bb663e63ec3fe02a323c0be3fee

See more details on using hashes here.

File details

Details for the file django_subdomain_tenancy-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_subdomain_tenancy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2dcc51068446f549c396b5b6627f3b51a8f017b4d967f16d2b2246c8dd454ff4
MD5 94ec6f793e289e21692b3434984b9e50
BLAKE2b-256 6f0181073a26df065db8f9bae64c02dea4a6f39579885b5598370a2b7c1fbbce

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