Check the version of Django

As you have read the title, this tutorial is all about checking the version of Django. You might be wondering what version of Django you are using right now, you might be stuck sometimes when the version does not support certain functions.

So no worries, by the end of this tutorial I hope you will be able to find the version of Django on your machine and additionally at the end of this tutorial, you will also get to know how to install a specific version of Django.

Method 1

The very first method to check the version of Django is simply to write python -m django –version in your terminal.

python -m django --version

This code will return the version of your Django in the format 3.2.9. If python doesn’t work replace it with python3 just like this: python3 -m django --version

Now in some cases, this might work fine:

python3.7 -m django --version

Make sure that you replace 3.7 with the current version that you are using,

Method 2

This method is almost similar to the first one and also gives the same output as the above method. The second method is django-admin –version

django-admin --version

Again it will only return 3.2.9 as output.

Method 3

The third method is known to almost all of us, but we might not have paid much attention to it. Do you remember what is the output when you write python manage.py runserver in your terminal.

python manage.py runserver

Here is the output,

Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
February 22, 2022 - 20:32:37
Django version 4.0.2, using settings 'myproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
E:\codespeedy\codespeedy_final\myproject\myapiapp\views.py changed, reloading.
Watching for file changes with StatReloader
Performing system checks...

You might have noticed version 4.0.2 in the above output.

Method 3

You can also check the Django version using pip. Do you want to know how? Let us move to the code section.

pip freeze

This will show you all the versions of all the modules installed in your system.

The output somewhat looks like:

Django==3.2.9
djangorestframework==3.13.1

Method 4

The next method in this tutorial is by using python IDLE. So, quickly open your IDLE and import django then write django.get_version().

import django
django.get_version()

It will result in the same output as the above methods 1 and 2.

'3.2.9'

Method 5

The above method can be modified a little bit to know the version of Django. The slight change in syntax is after importing django we need to write django.VERSION but the output varies.

import django
django.VERSION

The output looks like:

(3, 2, 9, 'final', 0)

So, we have learned overall 5 methods to know the version of Django installed in your system.

The additional information in this tutorial is about how to install any specific version of Django.

The first technique is to upgrade. You can upgrade Django using the syntax:

pip install --upgrade django

You might be required to downgrade the version of Django. You can accomplish this task by using the syntax:

 

pip install -v Django==3.0.5

 

You can replace it with the version you want to install.

These are the methods you can use to check the version of Django. Hope you enjoyed reading this tutorial. Feel free to comment and share your reviews on this tutorial.

KEEP READING!! KEEP CODING!!

Leave a Reply

Your email address will not be published. Required fields are marked *