skip to navigation
skip to content

Not Logged In

django_client_data 0.1.5

This allows Django to pass data to the browser.

Latest Version: 0.1.9

Django Client Data

This allows Django to pass data to the browser.


To get the latest stable release from PyPi

.. code-block:: bash

pip install django_client_data

Install the app, middleware, and context processor

.. code-block:: python





Call ``set_client_data()`` in your view to export values

.. code-block:: python

from django.views.generic import TemplateView
from django_client_data import set_client_data

class IndexView(TemplateView):
template_name = 'index.html'

def get(self, request, *args, **kwargs):
set_client_data(request, **{'foo': 'bar'})
return super(IndexView, self).get(request, *args, **kwargs)

Include ``client_data.html`` in your page

.. code-block:: django

{% include 'django_client_data/client_data.html' %}

The JavaScript object ``DJANGO.client_data`` will look like

.. code-block:: javascript

"DEBUG": false,
"STATIC_URL": "/static/",
"csrftoken": "gSlpOPyxHrdQH3KWUEkXx1wfyqGE7MDo",
"foo": "bar",
"url_args": [],
"url_kwargs": {},
"url_name": "index",
"user_full_name": null,
"user_pk": null,
"username": null


CLIENT_DATA_NAMESPACE (defaults to 'DJANGO') is the JavaScript global that will
be created as the namespace to contain the client data. The data is a property
of this global and is named 'client_data'.


Django Client Data works by attaching a ``client_data`` attribute on the request
object. The ``client_data.html`` template attaches a ``client_data`` property
to the JavaScript global indicated by CLIENT_DATA_NAMESPACE.


* add a "context processors" feature to client data so custom values can be

Run Tests

.. code-block:: bash

source venv/bin/activate
python django_client_data/tests/ test  
File Type Py Version Uploaded on Size
django_client_data-0.1.5.tar.gz (md5) Source 2014-06-08 4KB
  • Downloads (All Versions):
  • 11 downloads in the last day
  • 180 downloads in the last week
  • 772 downloads in the last month