Created
December 28, 2012 15:01
-
-
Save anonymous/4398563 to your computer and use it in GitHub Desktop.
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
| ... | |
| <script> | |
| Homes.reset({{ homes|jsonify }}) | |
| </script> | |
| ... |
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 | |
| 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