How to get an dictionary item in template
I'm sorry for my english, but on other groups nobody does not answers.
In view defined variables:
production = Production.objects.all ()
images = {}
for product in production:
try:
image = product.image_set.get (somefield = somevalue)
images [product.id] = image
except:
pass
Now the question is: how to access the elements of images in the
template?
{% for product in production %}
{{ product.title }}
{% if images %}
<Img src = "{{ images.<we must substitute product.id>.name }}" alt =
"{{ images.<we must substitute product.id>.title }}"/>
{% endif %}
{% endfor %}
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home