Checking Django Version in a Command Prompt

Posted on

As we already knew, Django is a web-based framework developed and it is using Python as its main programming language to be used for building web application.

It is also becoming quite make sense in order to start building web application based on Django, there is a prerequisite for Python installation before start programming and using it.

First of all, type the following command in the bash prompt or any command line available in the operating system after successfully installing Python as follows :

python

Successfully executing the command above will actually redirect the bash prompt into Python Interpreter which is presented in a form of shell. In this shell, it is possible to check the version of Django installed as long as Django has already been installed in the local host or workstation.

Just type the following syntax in the Python Interpreter shell :

import django;

The above is a syntax of Python used as a basic import statement which is used to import Django which is in this context Django itself is considered as a module. So, in order to be able to check the version of Django installed, first of all, it is needed to be imported.

print(django.get_version());

After importing Django module, the next thing is to type the above syntax to be able to check the version of the currently installed Django. The above execution syntax in the Python Interpreter in form of a shell is shown as the output result below :

user@hostname:~$ python
Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django;
>>> print(django.get_version());
1.9.4
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>>

Beside the execution shown of the above syntax inside in a Python Interpreter in form of a shell in order to retrieve the Django version, there is also another method that can be executed as follows :

user@hostname:~$ python -m django --version
1.9.4
user@hostname:~$ python

One thought on “Checking Django Version in a Command Prompt

Leave a Reply