Go to file
Matthew Cengia 64da7b252c
Revert "Switch to woodpecker"
2023-07-06 10:34:05 +10:00
.github Configure dependabot for Django 2023-06-05 13:17:01 -07:00
db Add prelim support for running outside Docker using SQLite and venv 2022-12-09 14:54:44 +11:00
django Add instructions for setting up initial app and URL routes 2023-06-08 22:38:28 -07:00
nginx More Docker image pinning 2023-06-05 12:55:22 -07:00
.dockerignore Add prelim support for running outside Docker using SQLite and venv 2022-12-09 14:54:44 +11:00
.drone.yml Revert "Switch to woodpecker" 2023-07-06 10:34:05 +10:00
.env.example Add prelim support for running outside Docker using SQLite and venv 2022-12-09 14:54:44 +11:00
.gitignore Add prelim support for running outside Docker using SQLite and venv 2022-12-09 14:54:44 +11:00
LICENSE Add MIT license 2021-06-07 23:25:16 +10:00
README.md Add instructions for setting up initial app and URL routes 2023-06-08 22:38:28 -07:00
docker-compose.dev.yml More Docker image pinning 2023-06-05 12:55:22 -07:00
docker-compose.prod.yml More Docker image pinning 2023-06-05 12:55:22 -07:00
docker-compose.traefik.yml More Docker image pinning 2023-06-05 12:55:22 -07:00

README.md

Dockerised Django

This is a Dockerised Django Project template

Getting started

  1. Clone this repo, cd into it, and copy the .env file:
git clone https://github.com/user/repo
cd repo
cp .env.example .env
  1. Edit the .env file and review its settings. At a minimum, you'll probably want to uncomment DEBUG=true for testing

  2. Start Django

  • To do so using Docker:

    docker-compose up -f docker-compose.dev.yml -d
    
  • To do so using a Python venv:

    NOTE: These instructions are only tested on macOS and Linux

    Perform the initial set-up (do this only once):

    # Create a virtual environment
    python3 -m venv .venv
    # Activate virtual environment
    . .venv/bin/activate
    # Install Python dependencies
    pip install -r django/requirements.txt
    # Change to the django dir
    cd django/
    # Run the Docker entrypoint script to set up an initial superuser etc
    ./docker-entrypoint.sh
    cd ..
    deactivate
    

    Start up Django (do this every time):

    # Activate virtual environment
    . .venv/bin/activate
    # Change to the django dir
    cd django/
    # Start Django
    ./manage.py runserver
    
  1. Log into admin console at http://localhost:8000/admin as root/root

Creating your first app

Now you've got Django up and running, you should be at the point where you can follow the Django documentation to create your first app. The short version of what you need to do from here is:

  1. Create an app:

If using Docker:

docker-compose exec app ./manage.py startapp myapp

If using a virtual environment:

./manage.py startapp myapp
  1. Edit both django/myproject/settings.py and django/myproject/urls.py, search for myapp, and uncomment the line as instructed.

  2. Set up appropriate views in django/myapp/views.py, and URLs in django/myapp/urls.py, before browsing to http://localhost:8000/

Notes

By default there is no docker-compose.yml, so docker-compose up won't work without specifying one of the other files.

docker-compose.dev.yml is designed for use during development. You probably also want to uncomment the DEBUG line in the .env file in this case.

docker-compose.prod.yml is designed for production.

docker-compose.traefik.yml is designed for production when using Traefik as a HTTP proxy

For convenience, any of these files could be copied or symlinked to docker-compose.yml so you don't need to specify the file with docker-compose -f file.yml.