Skip to main content

Integrate django with bower

Project description

Build Status Coverage Status https://pypip.in/v/django-bower/badge.png https://pypip.in/d/django-bower/badge.png

Easy way to use bower with your Django project.

Bower is a package manager for the web. It offers a generic, unopinionated solution to the problem of front-end package management, while exposing the package dependency model via an API that can be consumed by a more opinionated build stack. There are no system wide dependencies, no dependencies are shared between different apps, and the dependency tree is flat.

Read full documentation on read-the-docs.

Installation

Install django-bower package:

pip install django-bower

Add django-bower to INSTALLED_APPS in your settings:

'djangobower',

Add staticfinder to STATICFILES_FINDERS:

'djangobower.finders.BowerFinder',

Specify path to components root (you need to use an absolute path):

BOWER_COMPONENTS_ROOT = '/PROJECT_ROOT/components/'

If you need, you can manually set the path to bower:

BOWER_PATH = '/usr/bin/bower'

You can see an example settings file in example project.

Usage

Specify BOWER_INSTALLED_APPS in settings, like:

BOWER_INSTALLED_APPS = (
    'jquery#1.9',
    'underscore',
)

Download bower packages with the management command:

./manage.py bower install

Add scripts in the template, like:

{% load static %}
<script type="text/javascript" src='{% static 'jquery/dist/jquery.js' %}'></script>

In production you need to call bower install before collectstatic:

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

If you need to pass arguments to bower, like –allow-root, use:

./manage.py bower install -- --allow-root

You can use bower freeze to receive BOWER_INSTALLED_APPS with fixed current versions:

./manage.py bower freeze

You can call bower commands like info and update with:

./manage.py bower info backbone
./manage.py bower update

Python 3 support

django-bower supports python 3.3+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-bower-5.0.2.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file django-bower-5.0.2.tar.gz.

File metadata

File hashes

Hashes for django-bower-5.0.2.tar.gz
Algorithm Hash digest
SHA256 a47a1a25c65863135c0a9f71e1dc67e96fcc0f91795e5e49342dc161d31d116f
MD5 4a7ab29f5791f2f04b7ac6ba73a6b1a0
BLAKE2b-256 92f38fa416e81315edea293a44c22fa84e217fd99472c8540ce339bc1208d171

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page