Getting up and running with Django

This is quick guide to getting a Django project running on PC or Mac.

Firstly install python, visit https://www.python.org/downloads/ and select the download for your environment.

Create a new directory on your file system for your new project either using the windows/mac os or command line:

mkdir <project_name>

Then enter the new directory:

cd <project_name>

Within this directory, create a new python virtual environment:

MAC:

python3 -m venv venv

PC:

python -m venv venv

On my PC, as python is the only installed version I only need use the ‘python’ command. As you can see above, however on my Mac I use the ‘python3’ command as I have Python 2.7 installed from working with Python in Maya.

Activate the virtual environment:

MAC:

source venv/bin/activate

PC:

venv/Scripts/activate

Install Django into the Virtual Environment:

pip install Django

Once Django is installed in the venv (Virtual Environment), create a new project:

django-admin startproject <project_name>

This will create the folder structure and starting files in the project directory. At this point you will have a confusing number of nested directories, we can move everything up by 1 level:

mv <project_name>/manage.py ./
mv <project_name>/<project_name>/* <project_name>
rm -r <project_name>/<project_name>/

Finally start the project with:

python manage.py runserver