Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3456114
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:41:48+00:00 2026-05-18T09:41:48+00:00

I have a JSON object returned from server. It looks like this : {1:{id:1,name:autos},

  • 0

I have a JSON object returned from server. It looks like this :

{"1":{"id":"1","name":"autos"},
"2":{"id":"2","name":"business"},
"3":{"id":"3","name":"cities"},
"4":{"id":"4","name":"drama"},
"5":{"id":"5","name":"movies"},
"6":{"id":"6","name":"finance"},
"7":{"id":"7","name":"electronics"}}

So I’m rendering a template as a string with my JSON included :

<h3>Ugly, raw list. Yuck !</h3>
1: {{ interests }}
<ul>
    {% for k,v in interests.items %}
        <li>{{k}}. - {{ v }}</li>
    {% endfor %}
</ul>

template_name = 'socialauth/interests.html'
html = render_to_string(template_name, RequestContext(request, {'interests': ResultDict,}))

and as a result I’m getting :

<h3>Ugly, raw list. Yuck !</h3>
1: {&quot;1&quot;:{&quot;id&quot;:&quot;1&quot;,&quot;name&quot;:&quot;autos&quot;},&quot;2&quot;:{&quot;id&quot;:&quot;2&quot;,&quot;name&quot;:&quot;business&quot;},&quot;3&quot;:{&quot;id&quot;:&quot;3&quot;,&quot;name&quot;:&quot;cities&quot;},&quot;4&quot;:{&quot;id&quot;:&quot;4&quot;,&quot;name&quot;:&quot;drama&quot;},&quot;5&quot;:{&quot;id&quot;:&quot;5&quot;,&quot;name&quot;:&quot;movies&quot;},&quot;6&quot;:{&quot;id&quot;:&quot;6&quot;,&quot;name&quot;:&quot;finance&quot;},&quot;7&quot;:{&quot;id&quot;:&quot;7&quot;,&quot;name&quot;:&quot;electronics&quot;}}
<ul>   
</ul>

So it looks like my {{ interests }} variable is not treated as a dictionary. But why ? What more, now I’m including the rendered list to parent template which is also rendered as a string (because I’m loading it with ajax). And the final result looks as follows :

template:

<div class="connect-twitter" style="background:#f8f8f8">
    <div id="likes-list">
        {{ likes|safe }}
    </div>
    <a href="#" class="submit-step-2">Proceed</a>  
</div>

result:

Content-Type: text/html; charset=utf-8
{"html": "<h3>Ugly, raw list. Yuck !</h3>\n\n1: {&quot;1&quot;:{&quot;id&quot;:&quot;1&quot;,&quot;name&quot;:&quot;autos&quot;},&quot;2&quot;:{&quot;id&quot;:&quot;2&quot;,&quot;name&quot;:&quot;business&quot;},&quot;3&quot;:{&quot;id&quot;:&quot;3&quot;,&quot;name&quot;:&quot;cities&quot;},&quot;4&quot;:{&quot;id&quot;:&quot;4&quot;,&quot;name&quot;:&quot;drama&quot;},&quot;5&quot;:{&quot;id&quot;:&quot;5&quot;,&quot;name&quot;:&quot;movies&quot;},&quot;6&quot;:{&quot;id&quot;:&quot;6&quot;,&quot;name&quot;:&quot;finance&quot;},&quot;7&quot;:{&quot;id&quot;:&quot;7&quot;,&quot;name&quot;:&quot;electronics&quot;}}\n\n<ul>\n    \n</ul>"}

And when this code is inserted into html it looks just awful :

http://img204.imageshack.us/img204/3858/listaxv.png

What the hell ? Why it’s not rendering normally as strings but some ‘Content-type’ header is added ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:41:48+00:00Added an answer on May 18, 2026 at 9:41 am

    It looks like the template variable interests is just a string with the json response. The string gets escaped in the template, that’s why you end up with all the ". Check if the response from the server is correctly parsed.

    To verify the type, you can use the type class, i.e. type(ResultDict).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a json object returned from a third party api, it looks like:
I have dynamically created a xml string form a JSON object returned from server.
Ok so i have the json object returned back from my script and I
I have created a json object from ruby with cobravsmongoose, however the attributes have
I'm trying to alert id and subcategory in JSON string returned from the server
Hi I have a JSON object that is a 2-dimentional array and I need
say I have the following json object; {'fname':'john', 'lname':'Locke'} and the following text boxes
I have a request that returns a JSON object with a single property which
I have a JSON result that contains numerous records. I'd like to show the
I have a news feed where items in the feed are created from JSON

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.