Skip to main content

SSubdomain provides a clean way to manage multiple subdomains in a Django project. User role-based access control makes it easy to restrict parts of a site.

Project description

SSubdomain

SSubdomain is a Django package for managing subdomains.

Features

  • Subdomain routing
  • User role-based access control
  • Flexible configuration

Usage

Install from PyPI

pip install ssubdomain
python manage.py migrate

Add to INSTALLED_APPS

# settings.py

INSTALLED_APPS = [
    ...
    'SSubdomains'
]

Add to MIDDLEWARE

# settings.py

MIDDLEWARE = [
    ...
    'SSubdomains.middleware.SubdaomainsManagerMiddleware'
]

Define subdomains

# settings.py

SSUBDOMAINS_CONFIG = {

    'SUBDOMAIN_URLCONFS': {
        'www': 'project.urls.www',
        'blog': 'project.urls.blog'
    },

    'ROLE_FIELD': 'role',

    'ALLOWED_SUBDOMAINS_BY_ROLE': {
        'editor': ['blog']
    },

    'DISABLED_SUBDOMAINS_BY_ROLE': {
        'guest': ['blog']
    },
    'USE_MODEL': True,  # if you want to use model for subdomains, set this to True
    'MODEL': 'SSubdomains.Subdomain',
    # if you want to use custom  model for subdomains you must extend SubdomainBase model

}

Set up urlconfs

project/urls/www.py

from django.urls import path

# www url patterns 
urlpatterns = [
    ...
]

project/urls/blog.py

from django.urls import path

# blog url patterns
urlpatterns = [
    ...
]

Access via subdomains

http://www.example.com 
http://blog.example.com

Summary

SSubdomain provides a clean way to manage multiple subdomains in a Django project. User role-based access control makes it easy to restrict parts of a site.

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

SSubdomains-0.0.8b0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

SSubdomains-0.0.8b0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file SSubdomains-0.0.8b0.tar.gz.

File metadata

  • Download URL: SSubdomains-0.0.8b0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for SSubdomains-0.0.8b0.tar.gz
Algorithm Hash digest
SHA256 f3f978ff513b8d94fb344d03ff7b0c81a917dede57ed30c1e8c65b64709ff5e8
MD5 fabe39ca6e4ceae738c5e1eeda32d4dc
BLAKE2b-256 acc9c10ff55bb45ef26348c196678af78e6705cb73a858fdd20be44eae8adae9

See more details on using hashes here.

File details

Details for the file SSubdomains-0.0.8b0-py3-none-any.whl.

File metadata

File hashes

Hashes for SSubdomains-0.0.8b0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f53b0765ee0653f9e65a397dcb9f15a447525ce43dc508557167d13ad8cfc70
MD5 5f4eab6af9846a3b43ce0545bbb54afe
BLAKE2b-256 5f430d9b5c3f51f994610b63eb4d9cfe8c748d1d59d52ec7e3091290eba2a9ac

See more details on using hashes here.

Supported by

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