How to check Django version
I have to use Python and Django for our application. So I have two versions of Python, 2.6 and 2.7. Now I have installed Django. I could run the sample application for testing Django succesfuly. But how do I make sure whether Django uses the 2.6 or 2.7 version and what version of modules Django uses?
Django 1.5 supports Python 2.6.5 and later.
If you’re under Linux and want to check the Python version you’re using, run
python -V from the command line.
If you want to check the Django version, open a Python console and type
>>> import django >>> django.VERSION (2, 0, 0, 'final', 0)
Basically the same as bcoughlan’s answer, but here it is as an executable command:
$ python -c "import django; print(django.get_version())" 2.0
If you have installed the application:
$ django-admin.py version 2.0
Go to your Django project home directory and do:
>>> import django >>> print(django.get_version()) 1.6.1
I am using the IDLE (Python GUI).
If you have pip, you can also do a
and it will show your all component version including Django .
You can pipe it through grep to get just the Django version. That is,
josh@villaroyale:~/code/djangosite$ pip freeze | grep Django Django==1.4.3
import sys sys.version
For Django (as mentioned by others here):
import django django.get_version()
The potential problem with simply checking the version, is that versions get upgraded and so the code can go out of date. You want to make sure that ‘1.7’ < ‘1.7.1’ < ‘1.7.5’ < ‘1.7.10’. A normal string comparison would fail in the last comparison:
>>> '1.7.5' < '1.7.10' False
The solution is to use StrictVersion from distutils.
>>> from distutils.version import StrictVersion >>> StrictVersion('1.7.5') < StrictVersion('1.7.10') True
Type the following at the command prompt:
If django is installed it will print its current version (eg.
otherwise the shell will print an error message.
When you installed django, it was likely in only one environment. It is possible that you have two different versions of django, one for each version of python.
In from a Unix/Mac terminal, you can check your python version as follows:
$ python --version
If you want to know the source:
$ which python
And to check the version of django:
$ python -m django --version
There are various ways to get the Django version. You can use any one of the following given below according to your requirements.
Note: If you are working in a virtual environment then please load your python environment
python -m django --version
python manage.py --version
pip freeze | grep Django
python -c "import django; print(django.get_version())"
python manage.py runserver --version
Django Shell Commands
from django.utils import versionOR
(Feel free to modify this answer, if you have some kind of correction or you want to add more related information.)
For checking using a Python shell, do the following.
>>>from django import get_version >>> get_version()
If you wish to do it in Unix/Linux shell with a single line, then do
python -c 'import django; print(django.get_version())'
Once you have developed an application, then you can check version directly using the following.
python manage.py runserver --version
django-admin --version python manage.py --version pip freeze | grep django
Django will use the version of Python specified by the PYTHONPATH environment variable. You can use
echo $PYTHONPATH in a shell to determine which version will be used.
The module versions used by Django will be the module versions installed under the version of Python specified by PYTHONPATH.
pip list on LINUX TERMINAL and find Django and its version on list
pip freeze on cmd on Windows
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Entertainment & General News
- Games & eSport