I like to name the environment .venv
inside of the project directory, but @KenWhitesell’s method is great, too.
django-admin and manage.py
So there are two Django-specific commands that may be confusing here as well:
django-admin
manage.py
These are very similar. The main differences are:
manage.py
doesn’t exist until you run the commanddjango-admin startproject project_name [directory]
manage.py
loads your settings file into an environment variable calledDJANGO_SETTINGS_MODULE
You can read more about the two utilities in the docs.
These utilities have two commands that highly depend on where you’re at in your terminal or command line prompt because they create files for you:
If you click those links, it will take you to the Django documentation on these commands which explains that you can optionally specify the directory where you want the template files to be created.
Example
When I start a new project, I like to create the folder in my filesystem first. Then I cd
into it, start a Python virtual environment, install Django, and run startproject
. So something like the following…
cd C:\Users\Lance\Programming\Projects
mkdir Polls
cd .\Polls\
python3.11 -m venv .venv # creates my virtual environment
.\venv\Scripts\Activate.ps1 # this activates the venv in Powershell
python -m pip install django
django-admin startproject polls_project . # note the "dot" at the end to specify directory
python manage.py startapp statistics # when ready for a Django app
This puts my virtual environment at the base of this project folder alongside the manage.py
file and the base project directory.
Hope that helps! I think you’ll like it once you know the lay of the land!