Skip to main content

The foundation for building a SaaS product with Django

Project description

Django SaaS

A modular foundation for building multi-tenant SaaS products with Django.

Features

  • Multi-Tenancy: Flexible tenant discovery (Header, Path, Session).
  • Identity & Authentication: Robust user management with Password and SSO (Google, GitHub, Apple) support.
  • Organization & RBAC: Tenant-level organization with Members, Groups, and a global Permission/Role registry.
  • Custom Domains: Support for custom domain management and verification.
  • API First: Enhanced DRF integration with tenant-aware filters and permissions.
  • Developer Tools: Pre-configured SKILLs for AI-assisted development.

Install

pip install django-saas

Configuration

Add the required apps to your Django project's settings.py:

INSTALLED_APPS = [
    # ...
    'saas',
    'saas.identity',
    'saas.tenancy',
    'saas.sessions',
    'saas.tokens',
    'saas.domain',
    'saas.sso',
    'saas.drf',
]

AUTHENTICATION_BACKENDS = [
    'saas.identity.backends.ModelBackend',
    'saas.sso.backends.UserIdentityBackend',
    'django.contrib.auth.backends.ModelBackend',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    # SaaS Middlewares
    'saas.middleware.HeaderTenantIdMiddleware',
    'saas.middleware.PathTenantIdMiddleware',
    'saas.middleware.SessionTenantIdMiddleware',
    'saas.middleware.TenantMiddleware',
    'saas.sessions.middleware.SessionRecordMiddleware',
]

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.SessionAuthentication',
        'saas.tokens.authentication.TokenAuthentication',
    ],
    'DEFAULT_SCHEMA_CLASS': 'saas.drf.spectacular.AutoSchema',
}

URL Configuration

Include the SaaS URLs in your project's urls.py:

from django.urls import include, path

urlpatterns = [
    path('api/', include('saas.api_urls')),
    path('sso/', include('saas.sso.auth_urls')),
]

Documentation for AI Agents

This project includes specialized context for AI developers. If you are using an AI assistant, point it to AGENTS.md and the skills/ directory for automated workflows.

License

BSD-3-Clause

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_saas-0.2.1.tar.gz (144.1 kB view details)

Uploaded Source

Built Distribution

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

django_saas-0.2.1-py3-none-any.whl (186.8 kB view details)

Uploaded Python 3

File details

Details for the file django_saas-0.2.1.tar.gz.

File metadata

  • Download URL: django_saas-0.2.1.tar.gz
  • Upload date:
  • Size: 144.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_saas-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b9ab12d975b5ba1889a30dec468d9e9a9d1908b9cec1fd7179ff6292aa92b174
MD5 9e5d09770d4918682b5a1812169d506b
BLAKE2b-256 f1e4024fb38236fbc4b57673ae4ff5eef6f45d7169d3b278698a9985af5fe799

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_saas-0.2.1.tar.gz:

Publisher: pypi.yml on django-saas/django-saas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_saas-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: django_saas-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 186.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_saas-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ade5656f4bf72722c526c8ae1a2a2dfd973d3216ba3756fe0a3b2f069a7fb905
MD5 250f27df6bb8e9369f7a6cc43ecfe96e
BLAKE2b-256 0df5ee958dafb4e24c12260b7679d986b78f258aa0eb85c1021308604bb29b6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_saas-0.2.1-py3-none-any.whl:

Publisher: pypi.yml on django-saas/django-saas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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