Home

Awesome

Jace's Django Template

This is a cookiecutter template for a typical Django project following modern packaging conventions. It utilizes popular libraries alongside Make and Poetry to fully automate all development and deployment tasks. Check out the live demo: jacebrowning/template-django-demo

Build Status

Features

If you are instead looking for a Python library template, check out jacebrowning/template-python.

Usage

Install cookiecutter and generate a project:

$ pip install cookiecutter
$ cookiecutter gh:jacebrowning/template-django -f

Cookiecutter will ask you for some basic info (your name, project name, first app name, etc.) and generate a base Django project for you. Once created, run the code formatter to updates files based on your chosen names:

$ cd <github_repo>
$ make format

Deploying

This template builds projects intended to be deployed on Heroku:

$ heroku buildpacks:clear
$ heroku buildpacks:add https://github.com/moneymeets/python-poetry-buildpack.git
$ heroku buildpacks:add heroku/python

You'll also need to set the following environment variables in all environments:

NameValuePurpose
DISABLE_COLLECTSTATICtrueDisable automatic static files collection since bin/post_compile already does that
HEROKU_APP_NAME[staging-]<domain>Infer the domain name for staging and production
DJANGO_SETTINGS_MODULEconfig.settings.[staging]Specify which Django settings to use for the application
SECRET_KEY<generated>Securely encrypt passwords in the database
DATABASE_URLpostgres://USER:PASSWORD@HOST:PORT/NAMESpecify the database URL for the application to use, following the schema used by dj_database_url
BUGSNAG_API_KEY<secret>Optional API key to enable the Bugsnag integration
MAX_REQUESTS[_JITTER]<int>Optional values to help deal with memory leaks

Updates

Run the update tool, which is generated inside each project:

$ bin/update