Source code for the official Django Polls tutorial, which assumes you already have a virtual environment with Django installed.
From the command line these are the commands for a new virtual environment named .venv in Windows or macOS.
# Windows
$ python -m venv .venv
$ .venv\Scripts\Activate.ps1
(.venv) $
# macOS/Linux
$ python3 -m venv .venv
$ source .venv/bin/activate
(.venv) $
Then install the latest version of Django.
(.venv) $ python -m pip install django
Checkout out LearnDjango for dozens of free tutorials and premium courses to help you master web development with Python and Django.