Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 1.08 KB

README.md

File metadata and controls

42 lines (28 loc) · 1.08 KB

Hackathon Django Starter

This is a quick template for starting a Django app on a Docker container with postgresql.

Instructions

In docker-compose.yml, change the values of POSTGRES_DB, POSTGRES_USER, and POSTGRES_PASSWORD.

Run the following command to create a new app:

docker-compose run web django-admin startproject <YOUR_APP_NAME> .

Replace <YOUR_APP_NAME> with your desired app name. Don't forget the period . at the end, that specifies the current directory!

Once created, open <YOUR_APP_NAME>/settings.py file and replace the DATABASES = ... with the following:

# settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'postgres',      # Your POSTGRES_DB value
        'USER': 'postgres',      # Your POSTGRES_USER value
        'PASSWORD': 'postgres',  # Your POSTGRES_PASSWORD value     ... from docker-compose.yml
        'HOST': 'db',
        'PORT': 5432,
    }
}

Bring up the containers:

docker-compose up

Visit http://localhost:8000/ to see Django's hello world page.