List Info

Thread: Multiple choice conditionals in templates?




Multiple choice conditionals in templates?
user name
2006-08-30 09:15:26
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' %}<a
class="buy-tickets" href="#">Buy 

Tickets</a>{% endif %}
         {% if e.status == '2' %}<h3
class="sold-out">SOLD OUT!</h3> 
{% endif %}
         {% if e.status == '3' %}<h3
class="cancelled">Cancelled!</h3> 
{% endif %}
{% endfor %}
----------------------------------------

Obviously this doesn't work because you can't use
"==" in templates.  
So how can I achieve this?



Sean


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Multiple choice conditionals in templates?
user name
2006-08-30 09:30:44

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.livejourn
al.com
http://nrcfosshelpline
.in/web/



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Multiple choice conditionals in templates?
user name
2006-08-30 14:07:58
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 this?
>
> use ifequal
>
> -- 
>
> regards
> kg
> http://lawgon.livejourn
al.com
> http://nrcfosshelpline
.in/web/
>
>
>
> >
>
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )