tags:

views:

21

answers:

1

hi,

i have in my template:

    <select name="meetingTimeDay">
    {% for k in days2 %}
      <option value="{{ forloop.counter0 }}"{% ifequal c.meetingTime|date:"w", forloop.counter0 %}selected="selected"{% endifequal %}>{{ k }}</option>
    {% endfor %}
    </select>

where days2 is:

days2 = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')

but the ifequal doesn't work. i render out both forloop.counter0 and meetingTime|date:"w" and 1 day WILL match visually. I think it may be a casting problem.

any ideas?

A: 

Get rid of the comma separating the values

{% ifequal c.meetingTime|date:'w' forloop.counter0 %}

Also the if tag has come a long way

{% if c.meetingTime|date:'w' == forloop.counter0 %}

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#if

czarchaic
@czarchaic sorry but both of them suggetions result in: TemplateSyntaxError: 'if' statement improperly formatted
khany
The first suggestion should read 'ifequal', not 'if equal'. The 2nd suggestion will only work with Django 1.2 (or later).
msanders
@all ok thanks for everyones help. first, no variation of the above evaluation worked. second, i extracted the weekday() in python and sent it through as a separate variable to Django, and it works. Messy but it works.
khany