Django project templates are a little-known option that allows you to create new Django projects based on your own preferences and boilerplate. This means you can pre-install apps, templates and dependencies and have them already in place, predictably and consistently, when you start a new project.
This (currently WIP) project template is designed to make starting a new USWDS-based Django project as simple as possible, while including additional government-related boilerplate such as federated analytics tags.
- Be sure pipenv is installed:
pip install pipenv
- Create or navigate to the directory you're building your Django project in. Typically, this should be your Git repository.
- Grab the pipfile from this repo:
wget https://raw.githubusercontent.com/18F/18f-django-project-template/master/Pipfile
- Then use it to install Django and other dependencies you'll want for your project:
pipenv install
- Activate the pipenv shell (virtualenv) with
pipenv shell
- Now you'll start your project pulling from this repo for the template:
django-admin.py startproject --template=https://github.com/18F/18f-django-project-template/archive/master.zip project_name
. Be sure to replaceproject_name
with whatever your project should be named. - Move into the
project_name
directory you just created. - Create a
.env
for your environment variables. Theexample.env
included here is one good example. - Run
python manage.py runserver
and go take a look at your new project.
In development, the project template will create a simple sqlite db. When you prep your staging and prod environments, you'll want to be sure postgresql is ready for you.
Remember to go into your admin and set the site variables, so you don't show up as example.com
By default your AGENCY setting (used for analytics) is set to the project name. Since that's probably not what you want, you'll want to change that.
- Django 2.0+ support
base.html
based on HTML5 Boilerplate, optimized for USWDS, accessibility and best practices.- Uses Pipenv - the officially recommended Python packaging tool from Python.org.
- Get value insight and debug information while on Development with django-debug-toolbar.
- HTTPS and other security related settings.
- Some additional context processors.
- Cloud.gov integration, including Cloud UAA and database readiness.
Additional documentation is available in the /docs
folder.
- USWDS integration (NPM? Submodule? Preferences?)
- Improved Cloud.gov readiness
(Coming) It is possible to deploy to Cloud.gov or to your own server.
TBD