How to Build a Software as a Service with Django

Date Published: 2021-07-05

build-a-saas
Peng

Peng Akebuon

Tutorial Summary

⭐ In this series, we will build a Software as a Service ( Saas ). We first go through the definition of terms and talk about the relation between a Saas software and Multitenancy. Finally, we talk about the different approaches to solving multitenancy.

Materials/References

📚 Source Code
🔗 Django Tenant Docs

Part 1: What is a Saas and Multi-tenancy

Part 2: Build a Saas with django-tenant

# Middleware and Database Setup
MIDDLEWARE = [
    # add this at the top
    # django tenant middleware
    'django_tenants.middleware.main.TenantMainMiddleware',

    #........
]


# Setup Postgres database in settings.py
DATABASES = {
    'default': {
        # Tenant Engine
        'ENGINE': 'django_tenants.postgresql_backend',
        # set database name
        'NAME': 'saasy',
        # set your user details
        'USER': 'admin',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'POST': '5432'
    }
}

# DATABASE ROUTER
DATABASE_ROUTERS = (
    'django_tenants.routers.TenantSyncRouter',
)

Let's Connect

🔗 LinkedIn
🔗 Twitter
🔗 Join Our Discord Server

🔗 Academy Omen: GitHub