Lesson 8 of 60 – Check Django Version
13%

🔍 Check Django Version

After installing Django, it is important to check whether Django is installed correctly and which version is available in your current Python environment.

Note: Always check the Django version from the same environment in which you installed Django, especially when using a virtual environment.

1. Why Check the Django Version?

Checking the Django version confirms that Django is available in your current Python environment.

It is also useful when troubleshooting installation problems or working with a project that requires a particular Django version.

2. The Basic Django Version Command

The simplest command for checking the Django version is:

django-admin --version

If Django is correctly installed, this command displays the installed Django version.

3. Check Version Using Python

You can also check the Django version through Python:

python -m django --version

This method is especially useful when working with a particular Python environment.

4. Check Version Using pip

pip can also display information about the installed Django package.

python -m pip show Django

This command provides more information than just the version number.

5. Example Version Output

A successful version command may display output similar to:

5.x

The exact version displayed depends on the version installed in your environment.

6. Check Python Version Too

Django runs on Python, so checking the Python version can also be useful.

python --version

On systems where Python 3 is accessed as python3, use:

python3 --version

7. Check pip Version

You can also check the installed pip version:

python -m pip --version

This can help determine which Python installation is associated with pip.

8. Django Version Inside a Virtual Environment

If you installed Django inside a virtual environment, activate the environment before checking the version.

On Windows:

venv\Scripts\activate

Then:

python -m django --version

9. Linux/macOS Virtual Environment

On Linux or macOS, activate the environment first:

source venv/bin/activate

Then check Django:

python -m django --version

10. Why Environment Matters

You may have more than one Python environment on your computer. One environment may contain Django while another does not.

Therefore, always check the version from the environment used by your Django project.

11. Check Django with pip show

The following command displays Django package information:

python -m pip show Django

It can show details such as the package name, version, location and dependencies.

12. Find Django in pip List

You can list installed packages using:

python -m pip list

Look for Django in the displayed package list.

13. django-admin Version

The django-admin command can directly report the Django version.

django-admin --version

This is a short and commonly used command.

14. Python Module Version Command

Another reliable command is:

python -m django --version

Here, Python runs Django as a module and asks it to display its version.

15. Difference Between the Commands

Command Purpose
django-admin --version Displays the Django version
python -m django --version Displays Django version through Python
python -m pip show Django Displays Django package information
python -m pip list Lists installed Python packages

16. Django Command Not Found

If django-admin is not recognized, Django may not be installed in the current environment or the command may not be available through the system PATH.

Try checking with:

python -m django --version

17. Django Module Not Found

If Python reports that the Django module cannot be found, check whether Django is installed in the active environment.

python -m pip show Django

If Django is missing, install it using pip.

18. Install Django if It Is Missing

If Django is not installed in the active environment, run:

python -m pip install Django

After installation, check the version again.

19. Check the Version Again

After installing Django, run:

python -m django --version

The command should now display the installed Django version.

20. Check Django Location

The location of the Django package can be displayed with:

python -m pip show Django

Look for the Location information in the output.

21. Version and Project Compatibility

Django projects can depend on particular Django and Python versions.

Before installing or upgrading Django for an existing project, check the project's dependency requirements.

22. Check Version Before Creating a Project

It is useful to verify Django before creating your first project.

python -m django --version

Once the command works, you can continue with Django project creation.

23. Version Check on Windows

On Windows, you can use:

python --version
python -m django --version
django-admin --version

These commands help check Python and Django from the command prompt.

24. Version Check on Linux/macOS

On Linux or macOS, you can use:

python3 --version
python -m django --version
django-admin --version

Use the Python command that matches your system configuration.

25. Version Check Is Useful for Troubleshooting

When debugging a Django project, knowing the installed Django version helps identify environment and dependency differences.

You should also check whether the correct virtual environment is active.

26. Check the Active Python Environment

If you have multiple Python installations or virtual environments, verify which Python executable is active.

On Windows:

where python

On Linux/macOS:

which python

27. A Simple Version Checking Workflow

  1. Open the terminal.
  2. Activate the virtual environment.
  3. Check the Python version.
  4. Check the Django version.
  5. Check installed package information if necessary.
python --version
python -m django --version
python -m pip show Django

28. Django Version and requirements.txt

A project's dependencies can be stored in requirements.txt. You can create the file from the active environment using:

python -m pip freeze > requirements.txt

This records installed package versions for the environment.

29. Django Version Is Confirmed

If python -m django --version displays a version number, Django is available to that Python environment.

You are now ready to move forward and create a Django project.

30. Django Version Summary

There are several ways to check the installed Django version.

django-admin --version

or:

python -m django --version

For additional package information, use:

python -m pip show Django

Checking the version is an important step before starting Django project development.

📌 Key Points

  • django-admin --version displays the Django version.
  • python -m django --version checks Django through Python.
  • python -m pip show Django displays package information.
  • Activate the correct virtual environment before checking Django.
  • Checking the version helps troubleshoot installation and environment issues.
  • After confirming Django, you can proceed to create a Django project.

🧠 Quick Quiz

Question: Which command checks the Django version through Python?