Skip to content

Instantly share code, notes, and snippets.

@woodbridge
Forked from anonymous/template.html
Last active December 10, 2015 07:08
Show Gist options
  • Select an option

  • Save woodbridge/4398576 to your computer and use it in GitHub Desktop.

Select an option

Save woodbridge/4398576 to your computer and use it in GitHub Desktop.
Homes.reset(["{\"list_price\": 129900, \"number_of_bedrooms\": 3, \"formatted_list_price\": \"129,900\", \"address\": \"1201 27th St Northeast\", \"property_type\": \"Residential\", \"city\": \"Canton\", \"mls_number\": 1547472, \"monthly_maintenence_fee\": null, \"finished_sqft\": \"1256\", \"number_of_images\": 1, \"zipcode\": \"44714\", \"list_agent_id\": \"C391768\", \"state\": \"OH\", \"colisting_agent_id\": \"\"}", "{\"list_price\": 389900, \"number_of_bedrooms\": 3, \"formatted_list_price\": \"389,900\", \"address\": \"340 Cleveland Jacket Ct\", \"property_type\": \"Residential\", \"city\": \"Avon Lake\", \"mls_number\": 2507534, \"monthly_maintenence_fee\": null, \"finished_sqft\": \"2615\", \"number_of_images\": 2, \"zipcode\": \"44012\", \"list_agent_id\": \"323231\", \"state\": \"OH\", \"colisting_agent_id\": \"\"}", "{\"list_price\": 195000, \"number_of_bedrooms\": 3, \"formatted_list_price\": \"195,000\", \"address\": \"33234 Waterview Ct\", \"property_type\": \"Residential\", \"city\": \"Avon Lake\", \"mls_number\": 2506194, .....
...
<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