Install Django

Install Django using pip, confirm the version, understand LTS vs latest releases, and pin your dependencies with requirements files for reliable environments.

1. Introduction

In this guide we will install Django inside the virtual environment we created in the previous step. Because the environment is active, Django will only be available to this project and will not affect anything else on your machine.

  • Python 3.11 must be installed. If not, see Install Python.
  • Your .venv must be created and active. If not, see Setup venv.
  • Your terminal prompt should show (.venv) before you continue.

2. LTS vs latest release

Django releases come in two types: standard releases and LTS releases.

  • Standard releases — get bug fixes for about 16 months. Good for staying current, but you need to upgrade more often.
  • LTS (Long Term Support) releases — get security and bug fixes for at least 3 years. Recommended for production projects and tutorials.

In this tutorial series we use Django 5.2 LTS. It is the current LTS release and will be supported until at least April 2028. Using LTS means your setup stays stable throughout the entire series.

3. Install Django 5.2

Make sure your .venv is active — you should see (.venv) in your terminal prompt. Then run:

pip install "Django==5.2"

Pinning the exact version with ==5.2 ensures you get exactly what this tutorial uses. pip will download Django and its only dependency, sqlparse, automatically.

You will see output like this as pip installs:

Collecting Django==5.2
  Downloading Django-5.2-py3-none-any.whl (8.3 MB)
Collecting sqlparse>=0.3.1
  Downloading sqlparse-0.5.x-py3-none-any.whl
Installing collected packages: sqlparse, Django
Successfully installed Django-5.2 sqlparse-0.5.x

4. Verify the installation

After installation, confirm Django is available and on the correct version:

python -m django --version
# Expected output: 5.2

You can also drop into a Python shell and import Django:

python
>>> import django
>>> django.get_version()
'5.2'
>>> exit()

5. Pin your dependencies with requirements.txt

A requirements.txt file records exactly which packages and versions your project needs. Anyone who clones your project can recreate the same environment in one command.

Generate it now while only Django is installed:

pip freeze > requirements.txt

Open the file and you will see something like:

Django==5.2
sqlparse==0.5.x

To install from this file in a fresh environment later:

pip install -r requirements.txt

6. Upgrading Django later

You do not need to upgrade right now, but it is good to know how. When a patch release comes out (for example 5.2.1), you can upgrade with:

pip install --upgrade Django

After upgrading, always run pip freeze > requirements.txt again to update the pinned version. Patch releases only contain bug and security fixes — they do not break your project.

7. Next steps

Django is installed and verified. The next step is to create your first Django project using the django-admin command. This generates the initial folder structure and config files you need to start building.


Never miss a story on Django.wiki

Subscribe for fresh tutorials, snippets, and updates.

By subscribing you agree to our Privacy Policy.