1

My view function does the following:

search_parameters = {"words": "hello"} return render('mypage.html', {'results': results, 'search_parameters':search_parameters}) 

In my template, I thought I could get "hello" by writing:

{{search_parameters.words}} 

but it's blank.

What does work is looping through every value like so

{% for key,value in search_parameters.items %} 

but I'd really like to avoid doing that every time I need to get a value from the dictionary.

3
  • {{search_parameters.words}} would work. There's something else wrong. Commented Oct 21, 2012 at 19:51
  • 4
    Are you using render correctly? According to docs (docs.djangoproject.com/en/dev/topics/http/shortcuts/#render), the first required parameter is request which you do not pass. Maybe you meant to use render_to_response? Commented Oct 21, 2012 at 19:54
  • {{search_parameters.words}} did magically work once my computer and I had a good nights sleep. (I actually used render_to_response, not render) Commented Oct 31, 2012 at 10:06

1 Answer 1

1

Like miki725 have pointed out, you're missing the request arg

search_parameters = {"words": "hello"} return render( request, 'mypage.html', {'results': results, 'search_parameters':search_parameters} ) 

then you could do {{ search_parameters.words }} as you wish

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.