• Stars
    star
    128
  • Rank 281,044 (Top 6 %)
  • Language
  • Created about 12 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Collection of snippets that solve certain problems while deploying Django apps to Heroku

Django and Heroku Cookbook

Collection of snippets and scripts that solve certain problems when deploying Django apps to Heroku.

Scripts in the bin directory are post-compile hooks that are invoked by the heroku-buildpack-python's compile step. You can install them by copying the bin directory into the root directory of your Heroku application repository.

Installing NodeJS and Less compiler for static assets compilation in your Django app

Heroku provides a bunch of different buildpacks that target many popular platforms like Python, Ruby, NodeJS and Java web apps and backends. While this is great and allows you to deploy virtually anything with a simple git command, the out-of-the-box solutions offer a limited set of utilities that are available during the Slug compilation phase. In particular no NodeJS, NPM or LESS Compiler is available in the heroku-buildpack-python. This means that there is no straightforward way of compiling .less stylesheets during the app deployment.

Fortunately, the Python buildpack provides hooks for running pre-compile and post-compile scripts. This can be used for customizing the compilation step and running additional commands without the necessity of maintaining a separate fork of Heroku's buildpack. The only thing you need to do is to create a proper bin/post_compile bash script in the root directory of your application.

The bin and .heroku directories contain a set of scripts that can be used to install NodeJS/Less and invoke manage.py collectstatic and manage.py compress commands in your Django application:

Just copy them over to your app reposiory and have your Less stylesheets compiled with an assets compressor like Django Compressor.

Note: the empty /.heroku/collectstatic_disabled file deactivates the default collectstatic build step that is part of the Heroku's buildpack. This will prevent the build script from doing unnecessary work that is already handled by the above scripts.

A note on hosting static files on Amazon S3. Remember to enable the environment variables if you are using django-storages and uploading static assets to S3:

heroku labs:enable user-env-compile

Automatic Django configuration and utilities for Heroku

django-herokuify is a Django settings helper that makes is very easy to configure database, cache, storage, email and other common services for your Django project running on Heroku:

import herokuify

from herokuify.common import *              # Common settings, SSL proxy header
from herokuify.aws import *                 # AWS access keys as configured in env
from herokuify.mail.mailgun import *        # Email settings for Mailgun add-on

DATABASES = herokuify.get_db_config()       # Database config
CACHES = herokuify.get_cache_config()       # Cache config for Memcache/MemCachier

See the project page for more information.

All in one

Django Modern Template is a project template for easy bootstrapping a Django project that can be deployed on Heroku.

Clean virtualenv

Heroku caches Python virtual environment and all installed packages between project deploys.

Since the CLEAN_VIRTUALENV flag has been removed from the buildpack, currently the only way to clean app cache is by changing the runtime.

More Repositories

1

django-easy-pdf

PDF views, the easy way
Python
363
star
2

pywt

We're moving. Please visit https://github.com/PyWavelets
C
167
star
3

django-easy-pjax

Easy PJAX for Django
JavaScript
145
star
4

StackScripts

A bunch of StackScripts that I use to easily deploy full web+db+django stack at Linode.com
Shell
82
star
5

django-session-activity

List recent account activity and sign-out from all sessions opened on other computers
Python
63
star
6

django-modern-template

Modern Django project template
JavaScript
44
star
7

django-herokuify

Automatic Django configuration and utilities for Heroku
Python
38
star
8

django-request-id

X-Request-Id logging
Python
33
star
9

dj-cmd

Tired of typing `python manage.py runserver`?
Python
26
star
10

django-infinite-pagination

Efficiently paginate large object collections
Python
26
star
11

django-twilio-sms

Twilio integration for SMS-based Django apps
Python
14
star
12

web-screenshots

Sample Flask web app for taking web page screenshots using Selenium PhantomJS driver. Runs on Heroku.
Python
12
star
13

django-common-configs

Convention over configuration. Common settings for Django projects.
Python
10
star
14

jquery-expandme

Small jQuery plugin for expanding images and other content in articles.
JavaScript
5
star
15

sentry-on-dotcloud

Sentry realtime event logging deployment on DotCloud
Python
3
star
16

heroku-centrifuge

Python Centrifuge deployment on Heroku
2
star
17

ai-class-chrome-extension

Chrome Browser Extension for AI Class Forum
JavaScript
2
star
18

djutil

Common django utilities
Python
2
star
19

celery-worker-deadlock-debug

Debugging celery worker hangs and crashes - https://github.com/celery/celery/issues/3898
Python
1
star