[Answered ]-Django templates: get the list of passed objects and variable

-2👍

You can modify the dict that you passed to render_to_response so that it contains the list of variables.

In your views.py:

dic = {'a':1, 'b':2}
dic['keys'] = dic.keys()
return render_to_response('your_template.html', dic)

Then in your template:

{% for variable in keys %}
     {{ variable }}
{% endfor %}

4👍

I usually have django-debug-toolbar installed. It gives you all that information and much more.

Leave a comment