To get started with using the Django framework you can select an LTS (Long Term Support) version of Django and simply install it using pip.
If you are reading this tutorial between 1st April, 2021and 31st March 2024 then Django 3.2 is the version to use. It is an LTS or Long Term Support Version. The next release Django 4.2 is scheduled after that.
python --version
python -m pip install --upgrade pip
We do not need to download an exe or dmg version of Django manually. Django is a python package under PyPI (Python Package Index). We can install python packages under PyPI by using the package manager called pip.
pip install django==3.2
django-admin --version
Ubuntu or Mac OS might refer to python as python3. In this case, we can do aliasing like alias python = /usr/bin/python3. We may sometimes need to install pip as well.
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py
pip install django==2.2
Virtual environments can help maintain different software versions or Django versions under the same operating system. It is recommended if there are many users for your computer who would like to work with different versions of Python or Django.
To install virtual environment simply, run:
pip install virtualenv
To create a new virtual environment named myenv, run:
virtualenv myenv
To start/activate the virtual environment simply, run:
myenv\Scripts\activate
On a Mac or Linux environment use the below command to activate the virtual environment
source venv/bin/activate
To deactivate the virtual environment, run:
deactivate