Django JS Tools
Project description
Django.js provides tools for JavaScript development with Django.
This is currently a work in progress so don’t expect it to be perfect.
- Django.js is inspired from:
Installation
You can install Django.JS with pip:
$ pip install django.js
or with easy_install:
$ easy_install django.js
Add djangojs to your settings.INSTALLED_APPS.
Add djangojs.urls to your root URL_CONF:
urlpatterns = patterns('', ... url(r'^djangojs/', include('djangojs.urls')), ... )
Reverse URLs
The Django.js library expose reverse URLs to javascript. You can call the Django.url() method with:
an url name without arguments
Django.url('my-view');
an url name and a variable number of arguments
Django.url('my-view', arg1, arg2);
an url name and an array of arguments
Django.url('my-view' [arg1, arg2]);
an url name and an object with named arguments
Django.url('my-view', {arg1: 'value1', arg2: 'value2'});
You can use anonymous forms (variable arguments and array) with named arguments in URLs but you can’t use object form with anonymous arguments.
Constants
Django.js wraps some Django constants:
Django.STATIC_URL
Django.LANGUAGES
Django.LANGUAGE_CODE
Django.LANGUAGE_NAME
Django.LANGUAGE_NAME_LOCAL
Django.LANGUAGE_BIDI
Other features
When the django_js template tag is included in a page, it automatically:
Patch jQuery.ajax() to handle CSRF tokens
loads the django javascript catalog for all apps supporting it
- loads the django javascript i18n/l10n tools in the page:
gettext()
ngettext()
interpolate()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.