Hi,
I'm trying to render a template using a generic view of the
list_detail type. The list of objects I'm trying to render in the
template (which are offers) have an original_price and a
discounted_price and I'd like to display also the relative discount
(that is: (original_price-discounted_price)/original_price). For this
I'm passing a dictionary to the extra_context dictionary of the
generic view with offer.id as key and the relative discount as value.
Now in the template I have the following code where I'd like to access
the relative discount which is in the offers_discount dictionary. The
problem is due to the grouping I cannot use the for loop to iterate
over the dictionary. The way I'd like to do it would be as shown below
{{ offers_discount.{{offer.id}} }} but of course it doesn't work.
{% regroup offers_list by category as grouped %}
<ul>
{% for group in grouped %}
<li>{{ group.grouper }}
<ul>
{% for offer in group.list %}
<li>
<a>
offer name: {{ offer.name }} | offer discount:
{{ offers_discount.{{offer.id}} }}.
</a>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
The other related discussions on this newsgroup (dictionary lookup in
templates) don't consider the case of grouping where we can't iterate
over the dictionary in the classical way.
Do you have any suggestion on how to solve this problem?
Thanks a lot
Francesco
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---