Django + Heroku + Django-Pipeline = Happy Statics

Thu, Oct 18, 2012 3-minute read

I’ve been working on a site over the last few months called linkminded: We hope to go live soon, however, one of the many hurdles we’ve had to work through has been static content delivery.


We chose to use the Django development platform for our web framework. The platform is awesome and I highly recommend it. Django takes care of a lot of stuff. However by itself it does not handel static deployments easily.


We have chosen Heroku as our server host. They are a great company that makes it super easy to do deployments, (git push heroku master). Although Heroku is great, it appeared to lack some needed functionality, server side core librareis. Enter Heroku buildpacks, awesome packages that work kind of like AWS AMIs. We chose to use this build pack (git:// ) because it allows us to use Node and NPM.


Static content is one piece of web architecture and Django Pipeline makes it easy. Using django-pipline, in combination with less, we have easily managed static content. Pipeline does not deploy static content to a static content server however. It helps to combine your many JS, CSS, and LESS files together, based on configuration, so that deployments can be more easily managed. While keeping development simple.

Happy Static

Using Django, Heroku, and django-pipeline we’ve achieved simple and repeatable static content development. With an explanation of each piece out of the way, we can now get into how we did this.

Setup your project with django-pipeline:

The first step here is to make sure you have a Django application that actually needs to be deployed. I have a sample app for this blog post here: It is already setup and ready to go. Look at the bottom of the file to see the djanog-pipeline settings that are needed. ¬†You’ll also need to make sure you use {% raw %}{% compressed_css ‚ÄėPIPELINE_KEY' %}{% endraw %} and {% raw %}{% compressed_js ‚ÄėPIPLINE_KEY' %}{% endraw %} in your templates. ¬†Look at the templates in the example app for pointers and see how they relate to the django-pipeline config.

Next create a Heroku app

You will need to setup a Heroku app now. Here are the command I’ve used to setup our Heroku application:

You will also need to make sure you have lessc installed. This is able to happen easily because of the build pack we are using. Make sure you have an npm_requirements.txt next to your standard requirements.txt. Ours looks like this: Make sure you’ve committed all this code to master. Next do a ‚Äúgit push heroku master‚ÄĚ now your app should be deployed with statics working, (note this is form the dev server right now, you’ll want to update this to use a real CDN. Future blog post to come: Heroku + Django + AWS CDN


  • Example version here:¬†
  • Use this build pack: git://
  • Use a Procfile
  • Have an npm_requirements.txt
  • Have pipeline settings
  • Use¬†{% raw %}{% compressed_css ‚ÄėPIPELINE_KEY' %}{% endraw %} stuff in your templates
  • Define the compresor on the server to use node and lessc (see above)
  • Pay attention to requirements.txt (yuicompressor) and .gitignore
  • Had issues with our procfile for this example I just did: web: python collectstatic ‚ÄĒnoinput; python runserver$PORT