RequireJS integration

Django.js works with RequireJS but it requires some extras step to do it.

Preloading prerequisites

You should use the django_js_init template tag before loading your application with RequireJS.

{% load js %}
{% django_js_init %}
<script data-main="scripts/main" src="scripts/require.js"></script>

It works with django-require too:

{% load js require %}
{% django_js_init %}
{% require_module 'main' %}

See django_js_init.

shim configuration

You should add an extra shim configuration for Django.js:

    paths: {
        django: 'djangojs/django'

    shim: {
        "django": {
            "deps": ["jquery"],
            "exports": "Django"

Project Versions

Table Of Contents

Previous topic

Django javascript module

Next topic

Javascript test tools

This Page