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:
gitis 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.
python -m pip install Djangopython -m pip install Djangopy -m pip install DjangoInstall 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
maindevelopment branch:
git clone https://github.com/django/django.git- Activate the virtual environment and run the following command to install it locally:
python -m pip install -e django/python -m pip install -e django/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:
python -m django --versionpython -m django --versionpy -m django --versionThe above command is equivalent to running the following command:
django-admin --versionYou can alternatively run the following code inside Python shell, to verify installation:
import django
print(django.get_version())
# Prints the installed version of DjangoInstall Django REST Framework (DRF)
- Install DRF using the following command:
pip install djangorestframework- You can optionally install following packages as well:
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
