Tuesday, April 25, 2017

how to show image with index in python as context variable

hi,

i am trying to display a set of images with the use of index.
here is the code:
     <div>
         {% for item in product.productimage_set.all %}
        
            <img src="{{ item[0].image.url }}" style="height:100px;widht:50px"/>
      
       
         {% endfor %}

     </div>

the above code is displaying a set of images for one product .right.
i want to display it like {{ item[0].image.url }}
how can i do that ....?

regards.
shamaila

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/51fd8360-f106-4cc2-bde0-9756e690a926%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment