
Saleor is a great e-commerce open-source platform for building modern online stores. Uses Django framework and GraphQL to deliver a robust backend for creating PWA stores. Enhancing Saleor.io with multi-tenant abilities allows developing a SaaS platform that can manage multiple online stores from one place.
Django framework is a mature framework with many packages that can add multitenancy. There are two main points to evaluate when building such a solution: how to store tenants’ data and which package to use.
Storing data for multiple tenants can be achieved in three different ways:
Each solution has its pros and cons. There are many publications that discuss this in detail. Depending on how many tenants we are expecting or how much customization tenants need, we can choose one that suits us best. In our case, we have chosen “one schema per tenant”, which is a sensible middle ground.
Choosing a package requires evaluating:
We have chosen django_tenants package as it meets all our needs. It’s using database schemas to save tenants’ data, is under active development with a stable release cycle, and has comprehensive documentation.
Every tenant has its own schema in the database. There is also one public schema for storing admin and shared apps. Tenants are identified by their hostnames. Multi-tenant middleware analyzes every request and matches the tenant's hostname with their schema. Then it sets a connection to use the tenant’s schema and all queries are run in the tenant context. If no tenant is found, a 404 error is raised.
Writing a custom admin panel can be a daunting task requiring writing a lot of boilerplate code for CRUD operations. Instead, we can use Django to build an admin interface from models. It allows us to concentrate on adding additional functionality. The default tenant model contains only information about schema and domains associated with it. First, we can add fields for storing some more useful information about our tenants like their names, contact information, and activation status.
Writing a custom admin panel can be a daunting task requiring writing a lot of boilerplate code for CRUD operations. Instead, we can use Django to build an admin interface from models. It allows us to concentrate on adding additional functionality. The default tenant model contains only information about schema and domains associated with it. First, we can add fields for storing some more useful information about our tenants like their names, contact information, and activation status.
from django_tenants.middleware.main import TenantMainMiddleware
Adding multitenancy to Saleor.io platform is not a complicated task. By choosing the right tools and utilizing the power of the Django admin panel, we are able to create a good starting point for building a multi-tenant ecommerce platform.
Building something similar or facing technical challenges? We've been there.
Let's talk — no sales pitch, just honest engineering advice.
How to make the first step to establish a business relationship
How to start a business relationship? Personal and professional communication is one of the fundamentals which you should implement in your business relationship strategy.
How to Use Epidemic Sound MCP with Claude: AI-Powered Music Discovery for Developers
Learn how to set up and use Epidemic Sound MCP Server with Claude for AI-powered music discovery. Find the perfect tracks for your projects using natural language prompts.