python - How to convert string to list in Django template -
i want convert string list in django template :
data :
{u'producttitle': u'gatsby hard hair gel 150g', u'productprice': 0.0, u'productmrp': 75.0, u'hasvariants': 0, u'productsite': u'http://www.365gorgeous.in/', u'productcategory': u'', u'currency': u'inr', u'producturl': u'http://www.365gorgeous.in/gatsby-hard-hair-gel-300g-1.html', u'productdesc': u'a water type hair gel hard setting , gives hair firm hold non sticky hard setting , smooth touch firm hold wet spikes', u'productsubcategory': u'', u'availability': 0, u'image_paths': u'["full/548bc0f93037bd03340e11e8b18de33b414efbca.jpg"]'}
i want extract image paths above dict image paths in string u'["full/548bc0f93037bd03340e11e8b18de33b414efbca.jpg"]'
there way can convert ["full/548bc0f93037bd03340e11e8b18de33b414efbca.jpg"]
inside template ... know can done inside view can in template....
you write template filter runs string through json decode.
{% image_path in data.image_paths|your_custom_json_decode_filter %} {{ image_path }} {% endfor %}
this not idea though, why don't in view though?
Comments
Post a Comment