Update: I fixed it by uninstalling and re-installing Python/Django. Wasn't sure what was wrong.

I am trying to print out values from a dictionary to a html template using render (also tried render_to_response) but it doesn't seem to be working. The HTML template does not recognize any of the values I tried to pass into it.

Django code

def search(request): context = RequestContext(request) results2= [{'link':12, 'title':34, 'summary':56}, {'link':121, 'title':341, 'summary':561}] print results2 #is printed in command prompt, so this function is working return render_to_response('home.html', {'results2': results2}, context) #tried using render as well

HTML Template

{% extends "base.html" %} {% load staticfiles %} <form class="form-signin span8" id="user_form" method="post" action=""> {% csrf_token %} <!-- Display the search form elements here --> <input type="text" size="50" name="query" value="" id="query" /> <input class="btn btn-primary" type="submit" name="submit" value="Search" placeholder="Put Search"/> <br /> </form> <p>{{results2}}</p> <p>test1</p> <p>{{link}}</p> <p>test2</p> <div style="clear: both;"> <ol> {% for result in results2 %} <li> <strong><a href="{{ result.link }}">{{ result.title }}</a> </strong><br /> <em>{{ result.summary }}</em> </li> {% endfor %} </ol> </div>

In the command promp when the server is running and the function is called, it's printing 'results2', so the function 'search' is definitely working. However, the variables don't appear to be rendered.

View source for rendered page (equivalent to what's above):

<form class="form-signin span8" id="user_form" method="post" action=""> <input type='hidden' name='csrfmiddlewaretoken' value='Y4PfA0x8jH67jWUlTJfjbMzk0EAouPrp' /> <!-- Display the search form elements here --> <input type="text" size="50" name="query" value="" id="query" /> <input class="btn btn-primary" type="submit" name="submit" value="Search" placeholder="Put Search"/> <br /> </form> <p></p> <p>test1</p> <p></p> <p>test2</p> <p>test2</p> <div style="clear: both;"> <ol> </ol> </div>

So the list of dictionaries 'results2' is not being passed to the template. I'm not getting any errors.