python - Django: Parse JSON in my template using Javascript -


I have this in my opinion:

  string_location = myaddress2 geodata = [] place Geodata.append for geodata_results = len (geodata) data = {"geodata": geodata, "geodata_results") (geodata): Geodata_results} return to render_to_response ("business / business_view.html ", Data, context_instance = RequestContext (request))  

How do I" handle "/ convert geodata in JSON and pass it in my template so that I Can I "loop" it through "slip"?

Do I have the right to think that I can do it like this? If not, please suggest a better solution.

Thank you!

UPDATE

  var geodata = "[[Amp; quot; ml cusan street & amp; lt; br / & gt; monde City, Philippines & amp; quot ;, [10.3513819 99 99 99 99, 123.923535]], [& quot; Tomban & amp; BR; & gt; Cebu City, Philippines & amp; quot ;, [10.353527, 123.91352500000001] ]] ";  

I think JSON is not saved? How can I avoid special characters inside the JSSN string? I'm getting a new line error

For PHP, I'll json_encode () to fix it. As in this post: But how can I do it in Python / Django?

You can use - a JSON module:

  & gt; & Gt; & Gt; Import json & gt; & Gt; & Gt; Geodata = [[("here", (1003,3004)), ("there", (1.2.1.3))> gt; & Gt; & Gt; Json.dumps (geodata) '[[here], [1003, 3004]], ["There", [1.2, 1.3]]]'  

You can just embed As a result of the string inside a JavaScript script:

  



  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -