> {% for item in mydict.items %}
>the key: {{ item.0 }}
>the value: {{ item.1 }}
>{% for subitem in item.1 %}
>{{ subitem }}
>{% endfor %}
> {% endfor %}
UGH! How come django can make things so simple and complicated at the
same time? I personally dont use the django templ
You don't need the development version. You should be able to do
something like:
{% for item in mydict.items %}
the key: {{ item.0 }}
the value: {{ item.1 }}
{% for subitem in item.1 %}
{{ subitem }}
{% endfor %}
{% endfor %}
While not as pretty as the development version of d
>
> Note I am using 0.96, the production distro.
The ability to iterate through dictionaries is only available in the
*development* version.
Documentation URL:
http://www.djangoproject.com/documentation/templates/#for
>From the django site:
This can also be useful if you need to access the item
Great! I hope you can tell me what I'm doing wrong. Here's the
template:
{% for k, v in thedict.iteritems %}
{{ k }}, {{ v }}
{% endfor %}
{% for a1, a2 in thelist %}
{{ a1 }}, {{ a2 }}
{% endfor %}
and the views' index function
def index(request):
thedict = {'a': '1', 'b': '2' }
Ken wrote:
> For instance, I
> cant pass a dict or a list of lists to the template.
Actually it's not true, you can perfectly pass and access dicts and
lists and whatever in templates. Can you describe your specific case
that didn't work?
--~--~-~--~~~---~--~~
Y
I'm using 0.96 and find django's templates very frustrating. While I
find the ability to pass Python objects to the template and accessing
object attributes or methods to be really nice, this feature does not
extend to basic python objects like lists and dicts. For instance, I
cant pass a dict o
6 matches
Mail list logo