Skip to content

Instantly share code, notes, and snippets.

Created December 28, 2012 15:01
Show Gist options
  • Select an option

  • Save anonymous/4398563 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/4398563 to your computer and use it in GitHub Desktop.
...
<script>
Homes.reset({{ homes|jsonify }})
</script>
...
from django import template
from django.utils.safestring import mark_safe
import json
register = template.Library()
@register.filter
def jsonify(list):
flat = [item.to_json() for item in list]
blob = json.dumps(flat)
return mark_safe(blob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment