ifequal issues

1 view
Skip to first unread message

tomass

unread,
Mar 13, 2006, 6:37:27 PM3/13/06
to Django users
Hi Folks,

I'm having some issues with {% ifequal %}. What I'm trying to do is
have a drop down list remember the values that are sent on a get
request that is sent to the same page. I pass the value of the variable
(show_only in this case) back to the template, and then I have this
statement in the <option> section:

{% for job in jobs_list %}
<option value="{{ job.id }}"{% ifequal show_only job.id %} selected{%
endifequal %}>{% filter escape %}{{ job.shortsubject }}{% endfilter
%}</option>
{% endfor %}

Problem is, even when show_only is, for example, 2, and job.id is also
2 the ifequal statement doesn't seem to recognize that and is not
showing the crucial "selected" html which allows the drop down list to
"remember" the values that it should be doing.

Is this something related to numerical values (both are supposed to be
numerical values?

Thanks, Tom

SmileyChris

unread,
Mar 13, 2006, 6:55:42 PM3/13/06
to Django users
All variables that you "get" from the request come back as strings. So
'2' != 2
You could just set show_only=int(show_only) before you pass it to the
template.

tomass

unread,
Mar 13, 2006, 7:23:19 PM3/13/06
to Django users
Great, thanks! I thought it might be something like this. Should have
dug a little deeper...

Reply all
Reply to author
Forward
0 new messages