How to Build a Software as a Service with Django

July 5, 2021
build-a-saas

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

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',
)
        

Made With Traleor