Django

Django Installation

Install Django

Django Installation

Before installing Django, make sure you have Python installed on your system. Django requires Python 3.8 or higher.

Check Python Version

First, verify that Python is installed:

python --version
# or
python3 --version

Install Django using pip

The easiest way to install Django is using pip, Python's package manager:

pip install django

Or if you're using Python 3:

pip3 install django

Install Specific Django Version

To install a specific version of Django:

pip install django==4.2.0

Verify Installation

After installation, verify that Django is installed correctly:

django-admin --version

Or in Python:

import django
print(django.get_version())

Using Virtual Environment (Recommended)

It's best practice to use a virtual environment for your Django projects:

# Create virtual environment
python -m venv myenv

# Activate virtual environment
# On Windows:
myenv\Scripts\activate
# On macOS/Linux:
source myenv/bin/activate

# Install Django
pip install django

Note: Always use a virtual environment for your Django projects to avoid conflicts with other Python projects.