How to set up a new Django project

This post is a continuation of the django multi-tenancy series. In this part, we'll begin to implement the backend of the multitenant Django app. We'll be setting up a Django project from scratch.

The project source code up until this point is available on the github setup branch.

The project's final outcome can be explored using this live demo.

defynetech

Installing project dependencies

For this project, we'll need to have python 3+ installed. You can find the necessary steps in this digital ocean post. Next, we'll need to make virtual environments for installing project dependencies.

Install virtualenv

pip install virtualenv

Create a new virtualenv

virtualenv yourenvname -p python3.8

Activate virtual environment

source yourenvname/bin/activate

Run this command within the directory the virtual environment was created in.

Once your virtual environment is activated, there's a number of dependencies we'll be needing for the project:

  • Django and the djangorestframework: for an extensive introduction on how to use these libraries, check out my previous post on building web apis with django.
  • Djoser: REST implementation of Django authentication system. The Djoser library provides a set of Django Rest Framework views and endpoints to handle basic actions such as registration, login, logout, password reset, and account activation
  • django-rest-framework-simplejwt: provides a JSON Web Token authentication backend for the Django REST Framework.

My previous post on setting up Django APIs with JWT authentication should get you started on what JWTs are and how to implement them in Django. 😃

  • python-decouple: Decouple helps you to organize your settings so that you can change parameters without having to redeploy your app. These settings can be stored in parameters in ini or .env files. The library also allows the definition of comprehensive default values. Case in point;
from decouple import config

SECRET_KEY = config('SECRET_KEY')
DEBUG=config('DEBUG', cast=bool, default=False)

The repository has a requirements.txt and you can mass install all the dependencies by running pip install -r requirements.txt

Curious on some of the popular dependencies I use with Django? This post has some handy tools and resources for python programmers.

To kick off the new Django project, run the following once you've activated the previously created virtual environment.

django-admin startproject budgeting

Now to start with the first app that we'll require for the next section:

cd budgeting python manage.py startapp users

users will be our first app for this project and we'll put all the authentication logic here.

Next up, we'll cover user authentication in a multi-tenant app powered by django.🤠

open to collaboration

I recently made a collaborations page on my website. Have an interesting project in mind or want to fill a part-time role? You can now book a session with me directly from my site.

Sponsors

Some of the links below are affiliate links, which means I may earn a small commission — at no extra cost to you. I only recommend tools, products, and services I’ve personally used and found genuinely helpful in my work or learning journey. These sponsors quietly help keep the lights on around here — and I’m grateful for that. Please don’t buy anything you can’t afford or aren’t ready to put to use.

Scraper API

Scraper API

Scraper API is built for developers who need reliable, scalable web scraping without the headache of IP blocks or CAPTCHA walls. They handle IP rotation, CAPTCHA solving, and even headless browser emulation — so your scrapers look and behave like real users.

With over 20 million IPs, unlimited bandwidth, and built-in support for popular libraries like requests, BeautifulSoup, Scrapy, and Selenium, it works seamlessly across the Python ecosystem — and beyond. Whether you're using Node.js, Bash, PHP, or Ruby, integration is as simple as appending your target URL to their API endpoint.

If you're new to scraping, don’t worry — I’ve covered it extensively in the webscraping series, and it's all free.

Use this link + code lewis10 to get 10% off your first purchase. They’ve got a generous free plan — scale up only when you need to.

scraperapi

Digital Ocean

Digital Ocean

DigitalOcean makes it easy to launch, scale, and manage your cloud infrastructure — without the overwhelm.

Simple pricing. Powerful API. A clean UI that actually respects your time.

Use this link to get $200 in free credits for your first two months. Perfect for testing, launching, or scaling your next side project or startup.

Share to social media