On Tue, 2007-05-15 at 20:40 +0000, cesco wrote:
> 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.

I can't see how to resuscitate this approach, but a simpler solution
would be to put a get_discount() method on the model that returns the
computed value. Then it's just an attribute access in the template.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to