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 testi
As you say you have two versions of Python, I assume they are in different virtual environments (e.g. venv) or perhaps Conda environments.
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
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
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
django-admin --version
or django-admin.py version
./manage.py --version
or python manage.py --version
pip freeze | grep Django
python -c "import django; print(django.get_version())"
python manage.py runserver --version
import django
django.get_version()
OR
django.VERSION
from django.utils import version
version.get_version()
OR version.get_complete_version()
import pkg_resources
pkg_resources.get_distribution('django').version
(Feel free to modify this answer, if you have some kind of correction or you want to add more related information.)
You can do it without Python too. Just type this in your Django directory:
cat __init__.py | grep VERSION
And you will get something like:
VERSION = (1, 5, 5, 'final', 0)
Type in your CMD or terminal:
python -m django --version
You can get django version by running the following command in a shell prompt
python -m django --version
If Django is installed, you should see the version otherwise you’ll get an error telling “No module named django”.