This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

ABOUT

django_ajax provides some basic structure to make working with AJAX (and Javascript in general) more easy.

HOW

django_ajax provides various utils.

render_to_json

render_to_json is both implemented as a view and a decorator. The view does the real work, while the decorator is a utility function which itself uses the view to convert objects to json.

The view expects two arguments:

  • request
  • the object to output as JSON

It sets some HTTP headers to make sure the JSON can be loaded everywhere and nothing is cached in the browser.

The decorator just calls the original view function. If the response is not already a HttpResponse, it will be passed through the view as described above.

{% json %}

Template tag to render various objects as JSON.

Syntax:

<script type="text/javascript">
        var obj_as_json = {% json object %};
</script>

<script type="text/javascript">
        {# Output "null" of variable does not exist (prevents JS error) #}
        var obj_as_json = {% json object or null %};
</script>

{% ajax_cache %}

Utility template tag to pass objects to some JS function. May be used to implement JS-side caching of objects. This will speed up JS-driven apps, as the template can put out JS-objects then they are needed anyways. The tag makes sure every object will only be cached once, multiple calls will only output one JS-call.

Syntax:

<script type="text/javascript">
        {% comment %}
                Will output the same as "some_func.to.call({% json object %});"
                But only if object was not used in combination with
                "some_func.to.call" before.
        {% endcomment %}
        {% ajax_cache object using "some_func.to.call" %}
</script>

ajax_processors

Like context_processors, but used to put variables into the JS context. Provides JS_CONTEXT via a context processor, which can be rendered using {% json JS_CONTEXT %}. Example:

<script type="text/javascript">
        var config = {% json JS_CONTEXT %};
</script>

Uses settings.AJAX_CONFIG_PROCESSORS, which uses the same syntax as for context processors.

dango_ajax comes with three ajax processors (living in django_ajax.ajax_processors):

  • media: provides MEDIA_URL
  • static: provides STATIC_URL
  • session: provides basic authentcation information
    • includes AJAX login/logout urls and views

API

Uses object.ajax_data() in various places to allow defining method to convert models/… into dictionaries, which can be converted to JSON. This way you may pass model instances directly to {% json %} and the model may define which data to output.

Release History

Release History

0.2.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1-1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0-2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_ajax-0.2.0.tar.gz (5.2 kB) Copy SHA256 Checksum SHA256 Source Jul 7, 2014

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