I’ve encountered many situations that deal with managing the Django version. Whether you’re upgrading to use new features or downgrading to maintain compatibility, knowing how to change the Django version in your Python environment is essential.
In this article, I’ll walk you through simple, practical methods to check your current Django version and switch to the one you need. I’ll also share tips from my own experience to help you avoid common issues.
Let’s get started!
Change Your Django Version
When I first started working with Django, I often faced compatibility issues between projects. Some projects required Django 3.x, while others needed the latest 4.x release. Changing the Django version helps you:
- Use new features or bug fixes available in newer versions.
- Maintain compatibility with legacy codebases.
- Ensure smooth deployment in different environments.
Check out Add a Dropdown Navbar in Django
How to Check Your Current Django Version
Before changing the version, it’s important to know which version you currently have installed. Here’s a quick way to check it:
Open your terminal or command prompt and run:
python -m django --versionThis command will print the installed Django version, for example:
5.2.4You can see the output in the screenshot below.

Alternatively, you can check the version inside a Python shell:
import django
print(django.get_version())This will output the Django version as a string.
Method 1: Use pip to Change Django Version
The easy way to change your Django version is by using pip, Python’s package manager.
Step 1: Uninstall the Current Django Version
First, uninstall the existing Django version:
pip uninstall djangoYou might be prompted to confirm the uninstallation; type y and press Enter.
Step 2: Install the Desired Django Version
Next, install the version you want. For example, to install Django 3.2.18 (a popular LTS version in the USA market), run:
pip install django==3.2.18You can see the output in the screenshot below.

If you want the latest version, simply run:
pip install django --upgradeStep 3: Verify the Installation
After installation, verify the version again:
python -m django --versionThis should display the Django version you just installed.
Read Create a Function-Based View in Django
Method 2: Use a Virtual Environment to Manage Django Versions
In my projects, I always recommend using virtual environments. They allow you to isolate dependencies and manage different Django versions per project without conflicts.
Step 1: Create a Virtual Environment
Navigate to your project directory and create a virtual environment:
python -m venv venvActivate it:
- On Windows:
venv\Scripts\activate- On macOS/Linux:
source venv/bin/activateStep 2: Install the Desired Django Version Inside the Virtual Environment
With the virtual environment activated, install the Django version you want:
pip install django==4.1.7You can see the output in the screenshot below.

Step 3: Confirm the Version
Run:
python -m django --versionYou will see the Django version installed inside this virtual environment.
Why Use Virtual Environments?
- Keeps project dependencies isolated.
- Allows multiple projects to use different Django versions.
- Prevents system-wide package conflicts.
Check out Create a Web Form in Python Django
Method 3: Use pipenv for Version Management
If you prefer a tool that handles both virtual environments and package management, pipenv is a great choice.
Step 1: Install pipenv (if not installed)
pip install pipenvStep 2: Create a Project with a Specific Django Version
Navigate to your project folder and run:
pipenv install django==3.1.14This creates a Pipfile locking the Django version.
Step 3: Activate the Pipenv Shell
pipenv shellNow, inside this shell, you can run:
python -m django --versionMethod 4: Change Django Version in Requirements File
For projects with a requirements.txt file, specify the Django version explicitly:
django==4.0.5Then run:
pip install -r requirements.txtThis ensures all developers or deployment servers use the same Django version.
Read Build a Contact Form in Django using Bootstrap
Tips From My Experience
- Always test your project after changing the Django version. Some versions introduce breaking changes.
- Use Long-Term Support (LTS) versions like Django 3.2.x for production projects in the USA; they receive security updates for longer.
- Keep your
requirements.txtorPipfileupdated to avoid version drift. - When upgrading major Django versions, review the official Django release notes for backward-incompatible changes.
Changing your Django version in Python is straightforward once you know the right commands and tools. Whether you’re managing a legacy project or starting fresh, controlling your Django version ensures stability and access to the latest features.
You may like to read other Django articles:
- Add Google reCAPTCHA to Django Form
- Create a Contact Form with Django and SQLite
- Create a Form with Django Crispy Forms

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.