Django Multitenant SaaS Ecommerce
make testOverview
Section titled “Overview”Full Django SaaS app with compose, Kubernetes, tests, and AWS deployment assets.
What You Will Build
Section titled “What You Will Build”Architecture Diagram
Section titled “Architecture Diagram”Prerequisites
Section titled “Prerequisites”- Install or review: Python, Django, Celery, Redis, Postgresql, Docker, Terraform, Kubernetes.
- Use your own cloud account credentials and keep them out of commits.
- This project expects cloud resources, so verify budget alerts and cleanup first.
- Open the safety guide before running commands that create infrastructure.
Credentials And Cost Warning
Section titled “Credentials And Cost Warning”Cost risk is high. Cloud target: AWS. Cloud credentials needed: Yes. Always use your own account, never commit secrets, and confirm cleanup before creating paid infrastructure.
Step-By-Step Lab
Section titled “Step-By-Step Lab”Use this flow before you run commands:
- Read the cost and credential warning above.
- Review the validation, troubleshooting, cleanup, and portfolio proof sections below.
- Follow the original project guide preserved near the bottom of this page.
- Return to the validation and cleanup checks before you capture portfolio evidence.
Validation Checks
Section titled “Validation Checks”Run the project validation command before and after meaningful changes:
make testTroubleshooting
Section titled “Troubleshooting”- Run
make testfirst so local tooling issues are visible early. - If a command fails, check tool versions, working directory, and required environment variables.
- For cloud failures, confirm account identity, region, quotas, and least-privilege IAM.
Cleanup
Section titled “Cleanup”Cleanup is available or expected for this lab. Use the cleanup or destroy steps in the guide below, then confirm that local clusters, containers, cloud resources, buckets, state files, and CI secrets are no longer active.
Portfolio Proof
Section titled “Portfolio Proof”- Validation command output:
make test - Screenshot or terminal proof: Running container/app screenshot plus logs
- Notes explaining what changed, what failed, and how you fixed it
- Cleanup evidence, especially for cloud or Kubernetes resources
Original Project Guide
Section titled “Original Project Guide”The original README content is preserved here for lab-specific commands and context. Headings are intentionally demoted so the page outline stays focused on the standard lab flow.
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)”Introduction
Section titled “Introduction”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:
- Production Web Servers: Running
python manage.py runserverin 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. - 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.
Portfolio-Grade Runbook
Section titled “Portfolio-Grade Runbook”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:
- Runtime environment template: .env.example
- Docker Compose entrypoint: docker-compose.yml
- Kubernetes tutorial manifest: deployment.yaml
- EC2 Terraform variables example: deployments/terraform/terraform-aws-ec2-tf/terraform/terraform.tfvars.example
Prerequisites:
Section titled “Prerequisites:”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
Step 2 : Activate the environment:
Section titled “Step 2 : Activate the environment:”source ./venv/bin/activatesource ./venv/bin/deactivate ( To Deactivate )Step 3: Create project folder
Section titled “Step 3: Create project folder”mkdir appStep 4: Install Django
Section titled “Step 4: Install Django”pip install djangoStep 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-kubernetesStep 6: Create a new test app:
Section titled “Step 6: Create a new test app:”within the django project using the following command:
python manage.py startapp testappAdding a new app into the project
python manage.py startapp home apps/homeStep 7 : Execute ORM Data Migrations:
Section titled “Step 7 : Execute ORM Data Migrations:”python manage.py makemigrationspython manage.py migrateStep 8: Launch the django development server
Section titled “Step 8: Launch the django development server”python manage.py runserverStep 9: create admin user
Section titled “Step 9: create admin user”python manage.py createsuperuserstart using shell
Section titled “start using shell”bash ./server-entrypoint.shDocker
Section titled “Docker”bash ./run.shhttp://127.0.0.1:8585/API Docs
Section titled “API Docs”http://127.0.0.1:8585/swagger/Data Browser
Section titled “Data Browser”http://127.0.0.1:8585/data-browser/
GraphQL
Section titled “GraphQL”Extensions
Section titled “Extensions”python manage.py show_urls python manage.py graph_models finances -a -o finances_models.png
wagtail
Section titled “wagtail”Django ledger
Section titled “Django ledger”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_ledgerMulti tenant Settings
Section titled “Multi tenant Settings”pip install -r requirements.txtpython manage.py makemigrations financespython manage.py makemigrations apppython manage.py migrate financespython manage.py migrate apptenant = 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”Source Files On GitHub
Section titled “Source Files On GitHub”The full learning flow stays on this page. Open GitHub only when a step asks you to inspect code, fork the lab, or download source assets.