Heya all

Just posting in order to get some "clarifications" about the ifequal
(and to some extent, ifnotequal) tag.

I'll give a concrete example, in order to make things clear, for
everyone.



"result" is a tuple, which we get from a mysql query (cursor.fetchone).

I'm using some kind of template with forms and lists, on a model like
this:

  <select name="foobar">
    <option value="1" {% ifequal result.3 1 %}selected="selected"{%
endifequal %}>no</option>
    <option value="2" {% ifequal result.3 2 %}selected="selected"{%
endifequal %}>yes</option>
    ....
  </select>


Hence, sometimes, the result variable isn't set, when the query didn't
return any result at all.

According to the docs, I thought the variable was silently ignored when
not set, and the situation would be the same as in an "if" tag.
Nonetheless, it doesn't, it raises the VariableDoesNotExist exception,
instead of using some kind of TEMPLATE_STRING_IF_INVALID variable
replacement.

Solved the problem by surrounding with an "if" tag, but I'd like to
know if it's the "normal" situation. Googling didn't bring any answer
so far :/

Additional info: used django 0.90, upgraded to 0.91.

Please accept my apologies if this question was already raised, and
answered.

Thanking you in advance,

jy

Reply via email to