Re: Conditionals in Templates

2012-07-04 Thread Melvyn Sopacua
On 4-7-2012 0:49, Javier Guerra Giraldez wrote: > On Tue, Jul 3, 2012 at 3:39 PM, Bill Freeman wrote: >> The obvious ways are: >> >> 1. Provide a model method that returns a string representing the type >> of the instance, compare against that >> 2. Decorate the instance with an attribute giving t

Re: Conditionals in Templates

2012-07-03 Thread Javier Guerra Giraldez
On Tue, Jul 3, 2012 at 3:39 PM, Bill Freeman wrote: > The obvious ways are: > > 1. Provide a model method that returns a string representing the type > of the instance, compare against that > 2. Decorate the instance with an attribute giving the name of the type > as a string... 3. write a templa

Re: Conditionals in Templates

2012-07-03 Thread Bill Freeman
The obvious ways are: 1. Provide a model method that returns a string representing the type of the instance, compare against that 2. Decorate the instance with an attribute giving the name of the type as a string... Can't change the instance (I really think you can still decorate it in the view,

Re: Conditionals in Templates

2012-07-03 Thread Russ Abbott
Here's a workaround I came up with. I defined a class: class TableValue: def __init__(self, value): self.value = value self.is_list = isinstance(value, list) Then in the Template I wrote {% for row in rows %} {% f

Conditionals in Templates

2012-07-03 Thread Russ Abbott
I'm generating a table. I want the cells to be different depending on the type of the content. How do I test for the type of the content? I'd like to do something like this. {% for row in rows %} {% for cell in row %}

Re: Multiple choice conditionals in templates?

2006-08-30 Thread Sean Schertell
Thank you! I did read the template docs but I missed that one. Works great! :-) Sean On Aug 30, 2006, at 6:30 PM, Kenneth Gonsalves wrote: > > > On 30-Aug-06, at 2:45 PM, Sean Schertell wrote: > >> Obviously this doesn't work because you can't use "==" in templates. >> So how can I achieve

Re: Multiple choice conditionals in templates?

2006-08-30 Thread Kenneth Gonsalves
On 30-Aug-06, at 2:45 PM, Sean Schertell wrote: > Obviously this doesn't work because you can't use "==" in templates. > So how can I achieve this? use ifequal -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~

Multiple choice conditionals in templates?

2006-08-30 Thread Sean Schertell
How can I display different things in my template depending on the value of a single column in my database? For example: {% for e in events %} {% if e.status == '1' %}Buy Tickets{% endif %} {% if e.status == '2' %}SOLD OUT! {% endif