Django nvd3 Heroku

Matt Harley edited this page Apr 10, 2015 · 4 revisions

Bit of a pain!

But here's a simple way to do it...

Use django-nvd3 and django-bower

pip install django-nvd3 django-bower
pip freeze > requirements.txt
git add .
git commit -m "don't forget your requirements.txt!"

Use a multi-buildpack

heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git

Use the Node and Python buildpacks together

# ./.buildpacks
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/amanjain/heroku-buildpack-python-with-django-bower.git

Download bower using npm

# ./package.json
{"private": true,"dependencies": {"bower": "1.4.1"}}

User django-bower to collect its assets

# ./bin/post_compile
# install bower components
./manage.py bower_install

Tell django where to find bower

# settings.py
...
import os

APPLICATION_DIR = os.path.dirname(globals()['__file__'])
HEROKU = bool(os.environ.get('DATABASE_URL'))

BOWER_COMPONENTS_ROOT = os.path.join(APPLICATION_DIR, 'components')

# where to find your local bower
BOWER_PATH = '/usr/local/bin/bower'

if HEROKU:
    BOWER_PATH = '/app/node_modules/bower/bin/bower'

BOWER_INSTALLED_APPS = (
    'd3#3.3.13',
    'nvd3#1.7.1',
)
...

Credits