Reputation: 29557
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.
Upvotes: 1
Views: 1695
Reputation: 126
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
Upvotes: 1