Created
February 21, 2013 07:28
-
-
Save jtiai/5002929 to your computer and use it in GitHub Desktop.
Django template filter to output any object as JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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