DEV Community

Cover image for How to Check Django Version – Ultimate Guide 2020
hellocodeclub
hellocodeclub

Posted on • Updated on

How to Check Django Version – Ultimate Guide 2020

There are different ways you can check your django version. In this article I will share a couple of them. I will also share how you can upgrade and downgrade the django version. How you can uninstall django, something that you might do if you are running into problems and decide to uninstall it and install Django again.

Finding the django version can be useful if you want to make sure your python and django versions are compatible. I have also included a section to show how to find the python version that you are using.

Find your django version can also be useful to make sure a feature you are using, is supported that the django version installed

How can I check Django version?

The way you check your Django version depends on if you installed Django on you base python installation or you installed the module in a virtual environment. Let’s see first how to check your version on the base python installation.

Checking Django version with Idle

To achieve this, open the idle terminal and type the following:

import django
django.get_version()
Enter fullscreen mode Exit fullscreen mode

Output(you should get something similar):

'3.0.8'
Enter fullscreen mode Exit fullscreen mode

You could also use the following code, that will return the same results, but slightly different format:

import django
django.VERSION
Enter fullscreen mode Exit fullscreen mode

Output:

(3, 0, 8, 'final', 0
Enter fullscreen mode Exit fullscreen mode

Checking Django version with pip

You can also check the version through pip using. Run the following command on your terminal:

pip3 freeze
Enter fullscreen mode Exit fullscreen mode

Output:

Django==3.0.8  # Django version
docutils==0.14
dominate==2.5.1
Flask==1.1.1
Flask-Bootstrap==3.3.7.1
importlib-metadata==1.6.0
Enter fullscreen mode Exit fullscreen mode

If django is in your python installation, it will be listed along with any other module installed.

Check out your django version in a virtualenv or using the django scripts

Upgrade Django version

You can upgrade django and any module installed using the pip command. You can run the following command from your terminal, or the Pycharm terminal. As before, if you are working on a virtual environment, make sure you activate the environment before running the command:

pip install --upgrade django
Enter fullscreen mode Exit fullscreen mode

This will upgrade to the latest available version

Downgrade Django version

In case you would like to downgrade, you can do this via pip as well, using the following command:

pip install -v Django==3.0.5 #Replace with your version
Enter fullscreen mode Exit fullscreen mode

You can find a list with all the available django version here

As before in case you are working on a virtualenv, make sure it is activated. Or if you have several python version installed in your computer, make sure your pip command you are using belongs to the python installation you are using to run your python program. You can check this by running the linux which command from your terminal.

which pip
Enter fullscreen mode Exit fullscreen mode

The output should be same folder or subfolder as where your python version is installed.

Check out the following article to see how to install and uninstall python, and see your local python version

Discussion (0)