Django-heroku-bootstrap

Get your Django app running on Heroku in less than 5 minutes

View the Project on GitHub callmephilip/django-heroku-bootstrap

Django Heroku Bootstrap (DHB)

Get your Django app running on Heroku in less than 5 minutes. Really.

Quick start

#Your Amazon Web Services access key, as a string.
AWS_ACCESS_KEY_ID = ""

#Your Amazon Web Services secret access key, as a string.
AWS_SECRET_ACCESS_KEY = ""
heroku addons:add heroku-postgresql:dev
fab run
fab deploy

What's in the box

Check out requirements.txt for details on the dependencies.

DHB comes with an opinionated but powerful arsenal of tools that will help you take over the world with your web app in no time

All the settings are spread accross 6 files in the settings/ directory.

Static files

In settings/aws.py set the name of your S3 bucket for the project

#Your Amazon Web Services storage bucket name, as a string.
AWS_STORAGE_BUCKET_NAME = ""

Email

Assuming you've provided your AWS credentials in the settings file, email will just work. When running locally, emails will be dumped in the console. In production, DHB will send your love letters through Amazon SES (make sure you use a verified sender address when sending emails with SES)

from django.core.mail import send_mail

send_mail('testing mail', 'Here is the message.', 'bob@mysite.com', ['bob@gmail.com'], fail_silently=False)

Database please

Of course. You first need to get Postrgres on your Heroku

heroku addons:add heroku-postgresql:dev

And you should be set.

Redis

Vegetables are good for you. Especially when they help you build amazing apps. DHB uses Redis as a broker for Celery, which in turn is used for running background tasks.

If you don't have Redis running on your dev machine, get it here.

Heroku offers an add-on called "Redis to go". Let's activate it

heroku addons:add redistogo:nano

To see if it works

import redis
import os

redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost:6379')
redis_instance = redis.from_url(redis_url)
redis_instance.set('answer', 42)

Once again, when running locally, make sure you have Redis server running on your machine.

Celery

Celery allows you to run bacground tasks. DHB uses Celery coupled with Redis.

Celerybeat

Celerybeat allows you to have periodic tasks associated with your app. Tasks configuration is stored in settings/celerybeat.py (cunning, I know).

Running

git commit -a -m "initial commit"
fab deploy

Deployment script takes care of several things

** Pushing code to Heroku ** Moving static assets to S3 ** Synchronizing database

heroku ps 

You should see both celeryd and web running. If celeryd is not there, run the following

heroku ps:scale celeryd=1

Same applies to celerybeat (assuming you need it):

heroku ps:scale celerybeat=1
heroku open
fab run

Example App

/apps/examples contains a simple email form which you can use to test the setup. Navigate to /examples/email/ to try it.

Roadmap