how to upgrade django

How To Upgrade Django Version

Django is a popular python-based web development framework that offers many useful features. It is important to update Django to latest version in order to avail new features, improvements and security updates. Here is how to upgrade Django version. You can also use it to change Django version as per your requirement.

How to Upgrade Django Version

Here are the steps to update Django on your system.

1. Check Django Version

Open terminal and run the following command to get the version of your Django installation

# sudo python -c "import django; print(django.get_version())"
# 2.0.4

You can also log into python and run the following command to get Django version.

# python 
>>> import django 
>>> django.VERSION (2, 0, 0, 'final', 0)
>>> exit()

Also read : How to Install Django

2. Upgrade Django Version

Run the following command in terminal (not python console) to upgrade Django to latest version.

# sudo pip install django --upgrade

You can also use the following command for the same result.

# sudo python -m pip install -U Django

Also read : How to Uninstall Django

If you want to upgrade django to a specific version (e.g 3.3.1) then modify the above command, as shown below.

# sudo pip install --upgrade django==3.3.1

After you have upgraded Django, check its version again, as shown in step #1.

# sudo python -c "import django; print(django.get_version())"
# 3.3.1

Also read : How to Upgrade Python in Ubuntu

That’s it. As you can see, it is very easy to upgrade Django. Please note, if you have installed Django in a virtual environment, then run the above commands from within the virtual environment.

Leave a Reply

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