Getting npm, d3, nvd3, django-bower, django-bower-nvd3 and Heroku to play nicely together!

Wiki:

https://github.com/mattharley/matt/wiki/Django-nvd3-Heroku

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s