Skip to content

Instantly share code, notes, and snippets.

@jtiai
Created February 21, 2013 07:28
Show Gist options
  • Save jtiai/5002929 to your computer and use it in GitHub Desktop.
Save jtiai/5002929 to your computer and use it in GitHub Desktop.
Django template filter to output any object as JSON
from django import template
from django.utils.safestring import mark_safe
import json
register = template.Library()
@register.filter(name='json')
def json_dumps(data):
return mark_safe(json.dumps(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment