Installing Django
If you have already installed Django 5.0, you can skip this section and jump directly to the Creating your first project section.
Django comes as a Python module and thus can be installed in any Python environment. If you haven’t installed Django yet, the following is a quick guide to installing it on your machine.
Installing Django with pip
The pip
package management system is the preferred method of installing Django. Python 3.12 comes with pip
preinstalled, but you can find pip
installation instructions at https://pip.pypa.io/en/stable/installation/.
Run the following command at the shell prompt to install Django with pip
:
python -m pip install Django~=5.0.4
This will install Django’s latest 5.0 version in the Python site-packages
directory of your virtual environment.
Now we will check whether Django has been successfully installed. Run the following command in a shell prompt:
python -m django --version
If you get an output that starts with 5.0
, Django has been successfully installed on your machine. If you get the message No module named Django
, Django is not installed on your machine. If you have issues installing Django, you can review the different installation options described at https://docs.djangoproject.com/en/5.0/intro/install/.
All Python packages used in this chapter are included in the requirements.txt
file in the source code for the chapter, mentioned above. You can follow the instructions to install each Python package in the following sections, or you can install all requirements at once with the command pip install -r requirements.txt
.