This tutorial explains how to implement a multi-tenant web app in Django using the django-tenants and django-tenant-users packages, helping to answer: How to build a multi-tenant web app with Django? How to support multiple tenants in a Django project? The described solution is perfect for mid-sized to large Software-as-a-Service (SaaS) projects.
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by Nik Tomazic
Running Background Tasks from Django Admin with Celery
Django projects often involve long-running administrative tasks such as generating reports, removing inactive users, clearing auth tokens, and generating thumbnails. While these tasks are not as critical as tasks triggered by users, they can still significantly affect your web app's speed and availability if not appropriately handled. Instead of running administrative tasks on the main thread and blocking your web app, you should always utilize a task queue.
Django Query Optimization - Defer, Only, and Exclude
This article looks at the differences between Django QuerySet's , , and exclude() methods. -- Database queries are usually the bottlenecks of most web apps. Understanding how to write efficient queries can help you significantly speed up your apps. When working with databases, the rule of thumb is that fetching less data is generally faster. To minimize the amount of data fetched when working with Django, you can leverage the defer(), only(), and exclude() methods.
Deploying a Django App to AWS ECS with AWS Copilot
In this tutorial, we'll look at how to deploy a Django app to AWS Elastic Container Service (ECS) using AWS Copilot. Prerequisites: Python v3.11 (or newer) Docker v24.0.6 (or newer) An AWS account Objectives Explain what AWS Copilot is and look at its basic concepts. Deploy a Django application to AWS ECS using AWS Copilot CLI. Learn how AWS Copilot manages environmental variables and secrets. Spin up a PostgreSQL database using RDS and CloudFormation.
Avoid Counting in Django Pagination
This article looks at how to avoid the object count query in Django pagination. If you are using Postgres and would like to use an approximate count instead of entirely removing it, check out Approximate Counting in Django and Postgres. -- Django's default Paginator relies on the object COUNT(*) query to calculate the number of pages. As your database grows, this query can become considerably slow and may end up causing most of the page load time -- sometimes over 90%.
Track Errors in Your Python Flask Application with AppSignal
In this article, we'll look at how to track errors in a Flask application using AppSignal. We'll first bootstrap a Flask project, and install and configure AppSignal. Then, we'll introduce some faulty code and demonstrate how to track and resolve errors using AppSignal's Errors dashboard.
Approximate Counting in Django and Postgres
This article looks at how to speed up counting with Django and PostgreSQL. It covers two different approaches. -- As your Django project grows, you may notice that the admin site takes increasingly longer to load. This is mainly due to Django's paginator, which relies on the slow SELECT COUNT(*) query to calculate the number of rows in a table. At some point, this query itself will account for more than 95% of the page's loading time. But the issue isn't limited to the admin site.
Deploying a Django App to Azure App Service
In this tutorial, we'll look at how to securely deploy a Django app to Azure App Service. Objectives By the end of this tutorial, you should be able to: Explain what Azure App Service is and how it works. Deploy a Django App to Azure App Service. Spin up a Postgres instance on Azure. Set up persistent storage with Azure Storage. Link a custom domain to your web app and serve it on HTTPS. What is Azure App Service?
Clean Code in Python
In this article, we'll talk about clean code -- its benefits, different code standards and principles, and general guidelines on how to write clean code. What is Clean Code? Clean code is a set of rules and principles that help to keep our code readable, maintainable, and extendable. It's one of the most important aspects of writing quality software. We (developers) spend way more time reading the code than actually writing it, which is why it's important that we write good code.
Effectively Using Django REST Framework Serializers
In this article, we'll look at how to use Django REST Framework (DRF) serializers more efficiently and effectively by example. Along the way, we'll dive into some advanced concepts like using the source keyword, passing context, validating data, and much more. This article assumes that you already have a fair understanding of Django REST Framework. What's Covered?
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with Nik
Contact Nik, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack