Skip to content

Django Multitenant SaaS Ecommerce

Costhigh
Deployability container ready
Status local validated
Validation make test
Python Django Celery Redis PostgreSQL Docker Terraform Kubernetes aws terraform
Use the guide first.

The full learning guide is on this page. Open the repository files only when a step asks you to inspect code, fork the project, or download raw assets.

Automating Django , Celery , Redis and postgres deployment to AWS EC2 using Terraform ( Complete Guide)

Section titled “Automating Django , Celery , Redis and postgres deployment to AWS EC2 using Terraform ( Complete Guide)”

image

Automating deployment processes is crucial for modern web development, enhancing productivity and reliability. In this article, we focus on automating the deployment of a Django web application onto an Ubuntu Server hosted on AWS EC2.

🛡️ 2026 DevSecOps Enhancements (What You Will Learn)

Section titled “🛡️ 2026 DevSecOps Enhancements (What You Will Learn)”

Deploying Django to production requires strict adherence to DevSecOps principles, as many development defaults are highly insecure:

  1. Production Web Servers: Running python manage.py runserver in production is a critical security vulnerability. This project must transition to using a robust WSGI/ASGI server like Gunicorn or Uvicorn, ideally placed behind an Nginx reverse proxy to securely handle TLS/SSL termination and prevent slow-loris DDoS attacks.
  2. Django Secret & Configuration Security: The Django SECRET_KEY, DEBUG = True, and database credentials must never be committed to source control. In a DevSecOps deployment, these variables are injected dynamically at runtime via AWS Secrets Manager or HashiCorp Vault.

For the architecture diagram, local/Docker/AWS/Kubernetes deploy paths, run validation, cost controls, security checklist, and destroy procedure, see docs/portfolio-runbook.md.

Key artifacts:

Before we get into the good stuffs, first we need to make sure we have the required services on our local machine or dev server, which are:

  • Basic knowledge of Django
  • AWS Account
  • Github Account
  • AWS CLI installed and configured.
  • ECS CLI
  • Docker installed locally.
  • Typescript installed
  • Postman
  • Python 3
  • NPM
  • NodeJS
  • Terraform
  • A Domain name Hosted from any domain name provider ( Ex: AWS Route 53 )
  • Basic familiarity with YAML and GitHub workflows.
  • A Django project hosted in a GitHub repository
  • Basic knowledge of HTML or React
  • Any Browser for testing
  • Intermediate knowledge in Serverless Computing ( Ex : AWS Lambda , ECS,..)

You can follow along with this source code: GitHub - devcloudninjas/django-multitenant-saas-ecommerce-kubernetes: Django Multi-tenant … Django Multi-tenant , microservices , Kubernetes, Jenkins, Github Actions and Multiple Databases using docker, bash… github.com

Step 1: Create a virtual environment to hold all pip libraries installations

Section titled “Step 1: Create a virtual environment to hold all pip libraries installations”

If you don’t have virtualenv installed, you can install it by running the following command in your CMD after Python was installed:

Create virtual environment for Python python3 -m venv .venv

source ./venv/bin/activate
source ./venv/bin/deactivate ( To Deactivate )
mkdir app
pip install django

Step 5: Create a new Django project inside the project folder

Section titled “Step 5: Create a new Django project inside the project folder”

A Django app is a self-contained component of a Django project. It is a module that provides specific functionality, such as handling authentication, managing blog posts, or serving an API. An app should represent a single, specific functionality or purpose within the overall website.

django-admin startproject django-multitenant-saas-ecommerce-kubernetes

within the django project using the following command:

python manage.py startapp testapp

Adding a new app into the project

python manage.py startapp home apps/home
python manage.py makemigrations
python manage.py migrate

Step 8: Launch the django development server

Section titled “Step 8: Launch the django development server”
python manage.py runserver
python manage.py createsuperuser
bash ./server-entrypoint.sh
bash ./run.sh
http://127.0.0.1:8585/
http://127.0.0.1:8585/swagger/

@Swagger

http://127.0.0.1:8585/data-browser/ image

http://127.0.0.1:8585/graphql

python manage.py show_urls python manage.py graph_models finances -a -o finances_models.png

pip install pipenv (globally)

To activate this project’s virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run.

pipenv install django-ledger[graphql,pdf]
python manage.py test django_ledger
pip install -r requirements.txt
python manage.py makemigrations finances
python manage.py makemigrations app
python manage.py migrate finances
python manage.py migrate app

tenant = Client(schema_name=“test”, name=“test Company”)

domain = Domain(domain=“btest.localhost”, tenant=tenant, is_primary=True)

Thank you for Reading !! 🙌🏻, see you in the next article.🤘

For more information about the author visit

Section titled “For more information about the author visit”