A Complete Guide to Installing and Setting Up Django

This article provides a comprehensive guide to installing and setting up Django. It covers installing Python, creating a virtual environment, installing Django with pip, configuring a database, and optional production setup using Apache and mod_wsgi. This guide is suitable for beginners as well as experienced developers.

Installing and SettingDjango

~2 min read • Updated Mar 10, 2026

Introduction

Django is one of the most popular web frameworks in Python, designed for fast, secure, and scalable development. To start working with Django, you need to follow a few essential steps, including installing Python, setting up a database, and installing Django itself.

1. Install Python

Django is a Python-based framework, so the first step is installing Python.

  • Download the latest version of Python from the official website.
  • On Windows, you may find the “How to install Django on Windows” guide helpful.
  • On Linux and macOS, Python is usually pre-installed.

2. Install Apache and mod_wsgi (Optional)

If you only want to experiment with Django, you can use Django’s built-in lightweight development server. However, for production environments, using Apache with mod_wsgi is recommended.

Benefits of mod_wsgi:

  • Faster performance due to loading Python code into memory
  • Daemon mode allows better security and process control
  • Daemon processes can restart without restarting Apache

After installing Apache, ensure that mod_wsgi is enabled. Then follow Django’s documentation to configure it properly.

3. Set Up Your Database

Django supports several database backends:

  • PostgreSQL
  • MariaDB / MySQL
  • Oracle
  • SQLite (default)

Important Notes:

  • For small projects, SQLite is the easiest option.
  • For larger or production projects, use the same database you plan to deploy with.

Required Python Packages:

  • PostgreSQL → psycopg or psycopg2
  • MySQL/MariaDB → mysqlclient
  • Oracle → oracledb

DATABASES Settings in Django:

In your settings.py file, configure the following:


ENGINE: database backend  
NAME: database name  
USER, PASSWORD, HOST: required for non-SQLite databases

If you use Django’s migrate command, ensure your database user has permission to create and modify tables.

4. Install Django

The recommended and standard way to install Django is using pip.

Steps:

  • Install pip (if not already installed)
  • Create a virtual environment using venv
  • Activate the virtual environment
  • Run the installation command:
python -m pip install Django

5. Install the Development Version of Django

If you want the latest development version of Django:

  • Install Git
  • Clone the Django repository:
git clone https://github.com/django/django.git
  • Inside your virtual environment, run:
python -m pip install -e django/

To update Django later, simply run:

git pull

Conclusion

To install Django, you need Python, a virtual environment, and a suitable database. After that, installing Django with pip is straightforward. For production environments, Apache with mod_wsgi is recommended. You can also use the development version of Django to access the latest features.

Written & researched by Dr. Shahin Siami