Home

Boilerplate: Create A New Django Site/Project

Introduction

These are the basic Mac commands to create a new Django site (aka project). I expect the commands should work on most linux installs too, but haven't had a chance to check it. I'll do that and add a Windows version as time allows. There's also more about the process in the Boilerplate Details section further below.

Boilerplate Steps

  1. Specify the name for your site/project directory and intial module name (which I default to site_files for consistency):

  2. Run these Mac commands

    The last step will be to create a superuser accont which you'll need to fill out some details for. I use "admin" for the username, keep the email blank, and use a simple password when I'm making test boilerplate sites, but you can use whatever you want.

    terminal commands
    type deactivate &> /dev/null && deactivate
    mkdir django_example
    cd django_example
    python3 -m venv venv
    source venv/bin/activate
    pip install --upgrade pip
    python -m pip install Django
    django-admin startproject site_files
    git init
    echo "venv" > .gitignore
    echo ".env" >> .gitignore
    echo "*.log" >> .gitignore
    echo "*.pot" >> .gitignore
    echo "*.pyc" >> .gitignore
    echo "__pycache__" >> .gitignore
    echo "db.sqlite3" >> .gitignore
    echo "media" >> .gitignore
    git add .
    git commit -m "Initial commit"
    git checkout -b dev
    cd site_files
    python manage.py migrate
    python manage.py createsuperuser
  3. Start the server

    terminal commands
    python manage.py runserver
  4. Verify the default home page shows up

Next Steps

That's it for the site creation. If you're setting up for a new boilerplate example, the next step is:

Boilerplate: Add Basic Template And Static File Handling In Django

Boilerplate Details

~ fin ~