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!

Application variables passed from the server to the client.

Project Description

Var-js is a simple Django application that allows communication
variables from the server to the client.


pip install django-var-js



Quick start

1. Include the var-js URLconf in your project like this::

url(r'^', include('var_js.dj_var_js.urls')),

2. In the

from var_js.views import DjVarJs

def example(request):
variable = "To JavaScript"
dicc = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}

#Instance of class DjVarJs
pyvar = DjVarJs()

#Set values
pyvar.set("variable", variable , request)
pyvar.set("dicc_django", dicc, request)

return render_to_response('example.html', context_instance=RequestContext(request))

3. In the template::

<!DOCTYPE html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src=""></script>
<script src='{{STATIC_URL}}js/var_js/djvarjs.js'></script>
<script src='{{STATIC_URL}}js/example/main.js'></script>
<h1>App Django-var-js</h1>
<label id="key_js"></label>
<label id="dict_js"></label>

4. In the file .js::

var valor = DjVarJs.getKey("variable");

var arr = DjVarJs.getDict("dicc_django");
$("#dict_js").text("Clave1: " + arr['clave1'] + ", Clave2: " + arr['clave2'] + ", Clave3: " + arr['clave3']);

5. Visit
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-var-js-1.1.tar.gz (3.5 kB) Copy SHA256 Checksum SHA256 Source Apr 3, 2015

Supported By

WebFaction WebFaction Technical Writing 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 Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting