Skip to content

Installation

Pre-requisites

  • Python: Django is a Python-based web framework, so you’ll need to have Python installed on your system first. See this guide for instructions on installing Python.
  • git: git is required only if you want to install Django's development version.

Install Django

There are 3 ways to install Django:

Install an official stable release

This is the recommended way to install Django. To install the official release of Django, use this command:

TIP

It's strongly recommended to install and use Django inside a Python virtual environment. To set one up, see the Virtual Environments guide.

shell
python -m pip install Django
shell
python -m pip install Django
shell
py -m pip install Django

Install a distribution-specific package

Check the distribution-specific notes to see if your platform/distribution provides official Django packages/installers. These packages usually handle dependencies automatically and support system-managed upgrades, but they often lag behind and rarely include the latest release of Django.

Install the latest development version

This option is for enthusiasts who want the latest-and-greatest features and don’t mind running fresh, untested code. The development version may contain bugs, but reporting them helps the development of Django. Keep in mind that third-party packages are often less compatible with the development version than with the latest stable release.

Follow these instructions to get the latest development version of Django:

  • Clone the Django's main development branch:
shell
git clone https://github.com/django/django.git
  • Activate the virtual environment and run the following command to install it locally:
shell
python -m pip install -e django/
shell
python -m pip install -e django/
shell
py -m pip install -e django\

NOTE

To update Django to the latest development version, run git pull command inside the django directory.

Verify Installation

To verify Django installation, activate the virtual environment and run the following command:

shell
python -m django --version
shell
python -m django --version
shell
py -m django --version

The above command is equivalent to running the following command:

shell
django-admin --version

You can alternatively run the following code inside Python shell, to verify installation:

python
import django
print(django.get_version())
# Prints the installed version of Django

Install Django REST Framework (DRF)

  • Install DRF using the following command:
shell
pip install djangorestframework
  • You can optionally install following packages as well:
shell
pip install markdown                      # Markdown support for the browseable API.
pip install django-filter                 # Filtering support.
pip install drf-spectacular               # Schema generation support.
pip install djangorestframework-simplejwt # JSON Web Token authentication plugin for DRF.

TODO: Production Environment

If you plan on using Django on a production site, you'll also need Apache and mod_wsgi as well. Also, nginx + uWSGI as well?

TODO: Update this Section Later

References: https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/modwsgi/https://github.com/PirateDevCom/personal-docs/blob/main/docs/deployments/aws/Django%40EC2-Debian12.md