Django Installation¶
Django makes it easier to build better web apps more quickly and with less code.
-- djangoproject.com
The official Django website provides great resources for beginners to get up and running. But the package installer and virtual environment might confuse you.
-
Install Python
-
Install database (PostgreSQL)
-
Install
pip
pip
is the package installer for Python. You can usepip
to install packages from the Python Package Index (PyPI) and other indexes.pip
is automatically installed with Python downloaded from Python.org. -
Install
venv
The
venv
module provides support for creating lightweight “virtual environments” with their own site directories. Each virtual environment has its own Python binary and can have its own independent set of installed Python packages in its site directories. Also known asvirtualenv
in Python 2.venv
is automatically installed with Python downloaded from Python.org. -
Create virtual environment
The following command will create a new virtual environment in the current directory. This virtual environment and all its related files and data will be stored in the
.venv
folder. You can create and name thevenv
whatever you like but.venv
is fairly standard.What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?
There are many different packages and virtual environment managers available. Each created to solve a unique issue or to solve it better/faster/more efficient than the other. For now you can safely ignore all of them and just use the standard shipped
pip
andvenv
.Tip
Use a separate virtual environment for each project.
-
Activate virtual environment
To start using your newly created virtual environment you just have to run
activate
.If you have multiple environments you can run a specific environment by navigating to its
activate
file.Once activate, your command shell will be updated and include the name of your
venv
in parentheses. -
Install Django
Once your virtual environment is activated, you can use the command shell like you usually would. In this case we will install Django.
-
Git clone repository
At this point it is recommended to initiate and create your first
git commit
. This way you have a nice clean starting point in case anything goes wrong. For more info aboutgit
see the git notes. -
Install requirements
-
Deactivate virtual environment when done
Links¶
- Official Django website
- venv offical docs
- pypi.org Package Index
- Python.org
Created: October 5, 2022