Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

JavaScript tools for Django

Project Description

aino-jstools is a set of tools for working with JavaScript and Django. Primarily it compiles javascripts.

Design background

We wanted to make a tool that made including a bunch of JavaScripts in a template easy and clean and compiling all those JavaScripts into packed pieces in production for optimal performance. The other goal we wanted to achive was to expose urls defined in, MEDIA_URL, DEBUG settings to JavaScript code. Our future includes making a cleaner implementation for i18n in JavaScript than the one provided by Django.


  • Django 1.x
  • Python 2.5+
  • Java (for compiling JavaScripts)


Include jstools in INSTALLED_APPS in your project settings. Optionally include the jstools/ in your

(r'^jstools/', include('jstools.urls'))

Template usage

First define your scripts in a template as follows:

{% scripts "js/mysite-min.js" %}
    {% url jshelper %}
{% endscripts %}

When settings.DEBUG is True this will translate to:

<script src=""></script>
<script src="{{ MEDIA_URL }}js/a.js"></script>
<script src="{{ MEDIA_URL }}js/b.js"></script>
<script src="{% url jshelper %}"></script>

When settings.DEBUG is False this will translate to:

<script src="{{ MEDIA_URL }}js/mysite-min.js?TIMESTAMP"></script>

where TIMESTAMP is based on modification date of {{ MEDIA_ROOT }}js/myste-min.js


Compiling all defined scripts is as simple as running:

python buildjs

If you are using the default filesystem and/or app_directories this management command will find all templates with {% scripts %} tags and compile its contents into the first argument of the tag.

jshelper view

This view will output named urls, settings.MEDIA_URL, settings.DEBUG (I suggest you override this in your template unless you want to recompile the script when you change your DEBUG setting) for use in your JavaScript code. You will have access to a JavaScript object named JSTOOLS by default, you can change the name by setting JSTOOLS_NAMESPACE.


This function will get named urls defined in your First argument is the name of the named url, subsequent arguments are arguments passed to that pattern. Examples:

JSTOOLS.get_url('blog_entry', 2010, 04, 25, 'aino-jstools');

Release History

This version
History Node

History Node

History Node

History Node

History Node

History Node

History Node

Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(3.8 MB) Copy SHA256 Hash SHA256
Source None Mar 25, 2011

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting