Python Change Django Version

In this Django tutorial, we will learn how to change the Django version, and we will also learn different techniques to change the version of Django. The list of topics covered in the article is given below.

  • Reasons to upgrade Django Version
  • How to check Django Version
  • Python change Django Version
  • Python change Django Version Pycharm

Reasons to change Django Version

While changing the Django version is a complex process, it has several benefits also. So in this section, we’ll learn the reasons for upgrading the Django version.

  1. Additional features have been added.
  2. Improvements have been made.
  3. Bugs have been fixed.
  4. Updating as each current Django release becomes available reduces the agony of future upgrades by keeping your code up to date
  5. “Long Term Support” (LTS) versions are indicated on some Django framework releases. For a three-year span, LTS versions receive security and bug patches. The security risk on your website grows if you use an unsupported version of Django.
  6. It defends your website against cyber-attacks.
  7. Maintain your server at all times.
  8. Protect your data from unauthorized access and theft.
  9. Benefits development teams in terms of productivity.
  10. It also helps your development staff to spend less time and money on security and bug.
  11. It also liberates your development team to concentrate on website upgrades or revenue-generating projects.

Also, read: Python Django vs Flask

How to check Django Version

You should know which version of Django you’re using before altering it. In this section, we’ll go through different methods for checking the Django version.

The first way to find out what Django version you have is to start your server and look at the version number.

Command to run the Django server:

python runserver

Open a terminal window, navigate to your project directory, then type the command to start the Django server. This is what you’ll get as a result:

how to check django version
Django Version

The second technique to check Django’s version is the freeze command of the pip module. This command displays the packages that we installed via pip, along with their versions.

Command to check the version:

pip freeze

When you’re in the virtual environment, open a terminal window and type this command to check Django’s version.

check django version
Django Version

The third technique to check the Django version is using the shell.

Code to check Django Version:

import django

Firstly stop the server after this open a terminal window, then type the python shell command to launch the python manage shell. After that, type the above-mentioned code and press enter to run it.

how to get django version
Django Version

The fourth way to check the Django version is the command.


python version

To acquire the Django version, first, stop the server (if you haven’t already), then open a terminal window and type the command mentioned above.

django version
Django Version

Read: How to install Django

Python change Django Version

In this section, we’ll look at a few possible ways to change the version of Django. We can update Django to the most recent version or downgrade to an older version.

Upgrage Django Version

In many instances, you’ll need to update your Django-related dependencies to the newest version. As some of your dependencies may not yet support the new Django version that was newly released or if dependencies aren’t kept up to date. In certain cases, you may need to wait until updated versions of your dependencies are released.

Command to upgrade Django Version:

pip install django --upgrade
python -m pip install -U django
python -m pip install --upgrade django

Open a terminal window and type any of the commands listed above. It will upgrade to the most recent version of Django and uninstall the previous version automatically.

The output is as below:

python change django version
Django Version

You can see that the version of Django I installed is 3.2.12.

Upgrade Django Version

The outputs demonstrate that it will remove the 3.2.12 version and replace it with the most recent release, 4.0.2.

Degrade Django Version

Downgrading the Django version is not a good idea, but if there are particular needs that demand it, you can do so. The commands listed below are used to downgrade the version as well as change the version to a specified one.


pip install django==<specific version>
pip install --upgrade django==<specific version>

Type any of the commands given above in a terminal window. It will remove the previous version and downgrade to a certain version or install the specific version.

python django modify version
Check Version

The installed Django version is 4.0.2, as you can see.

python degrade django version
Downgrade Django Version

We’re going to uninstall Django version 4.0.2 and install Django version 3.1.14.

python django specific version
Upgrade Django to Specific Version

We’re going to upgrade Django to the specific version 3.2.12.

Read: How to setup Django project

Python change Django Version Pycharm

In this section, we’ll learn how to use the pycharm editor using GUI to change Django Version to a specified version.

The following steps are used:

  • Pycharm Editor should now be open.
  • On the top right bar, select File. And then go to the Settings tab.
python change django version pycharm
modify django version pycharm
  • First, we need to select the Project.
python django version pycharm
  • Then, under the project, select Python Interpreter.
python django modify version pycharm
Python Interpreter
  • Then double-click on the Django package to open it.
change django version pycharm
  • Select the version you want by checking the box Specify version.
pycharm alter django version
Specify Version
  • Install the package by pressing the Install Package button.
pycharm change django version
  • In the backend, pip command installs specify version Django.

To install a specific version of Django, you can simply use the pip commands mentioned in the previous section.

You may also like to read the following Django tutorials.

In this tutorial, we will learn how to change the Django version using multiple techniques. And, we also discussed the following topics in the post.

  • Reasons to upgrade Django Version
  • How to check Django Version
  • Python change Django Version
  • Python change Django Version Pycharm