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
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.
To achieve this, open the idle terminal and type the following:
import django django.get_version()
Output(you should get something similar):
You could also use the following code, that will return the same results, but slightly different format:
import django django.VERSION
(3, 0, 8, 'final', 0
You can also check the version through pip using. Run the following command on your terminal:
Django==3.0.8 # Django version docutils==0.14 dominate==2.5.1 Flask==1.1.1 Flask-Bootstrap==220.127.116.11 importlib-metadata==1.6.0
If django is in your python installation, it will be listed along with any other module installed.
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
This will upgrade to the latest available 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
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.
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