Skip to content

nvbn/django-bower

Repository files navigation

Django-bower

Build Status

Coverage Status

image

image

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:

Add django-bower to INSTALLED_APPS in your settings:

Add staticfinder to `STATICFILES_FINDERS`:

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

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

You can see an example settings file in example project.

Usage

Specify BOWER_INSTALLED_APPS in settings, like:

Download bower packages with the management command:

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`:

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

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

You can call bower commands like info and update with:

Python 3 support

django-bower supports python 3.3+