~allanlesage/+junk/helipad-coverage-slurping

« back to all changes in this revision

Viewing changes to deployment/django-jsonfield-0.9.3/jsonfield/templatetags/jsonify.py

  • Committer: Allan LeSage
  • Date: 2013-04-09 19:01:31 UTC
  • mfrom: (54.1.14 helipad-stack-view)
  • Revision ID: allan.lesage@canonical.com-20130409190131-ggh3emz3xga2yql0
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from django import template
 
2
from django.utils import simplejson as json
 
3
from django.utils.safestring import mark_safe
 
4
from jsonfield.utils import TZAwareJSONEncoder
 
5
 
 
6
register = template.Library()
 
7
 
 
8
@register.filter
 
9
def jsonify(value):
 
10
    if getattr(value, 'all', False):
 
11
        value = list(value)
 
12
    return mark_safe(json.dumps(value, cls=TZAwareJSONEncoder))