Installing Django Bower to manage Javascript in a VirtualEnv

Posted by: Michael Best 5 years, 6 months ago

Add nodeenv and django-bower to your requirements
- Python 2.6 will require ordereddict as well
- Patch to use ordereddict instead of the built-in Python 2.7 version
- https://github.com/nvbn/django-bower/pull/43

pip install nodeenv
pip install django-bower

Install node inside the VirtualEnv from prebuilt package
- compiling node turned out to be complicated in some of my stacks

nodeenv --prebuilt -p

Install bower using npm

npm install -g bower

Django settings.py

STATICFILES_FINDERS
"djangobower.finders.BowerFinder",

BOWER_COMPONENTS_ROOT = PROJECT_ROOT + '/assets/'
BOWER_INSTALLED_APPS = (
'jquery',
'bootstrap',
)

Installing Components and Collecting Static

./manage.py bower install
./manage.py collectstatic