Comparando el bucle i from con el valor pasado

I use a Django 1.2 templates in Google App Engine wepage.

I pass a agemin to template to mark option as selected in html form. But code below dosn't work.

El age es creado por range(18,100)

How to compare 'i' with agemin?

    {{agemin}} //this is for example 23
    <select name=agemin><BR>
        {% for i in age%}
            <option {% if i == agemin %}selected{% endif %}>{{ i }}</option>


preguntado el 09 de marzo de 12 a las 15:03

1 Respuestas

Utilice el si es igual tag:

{% ifequal agemin i %}

respondido 09 mar '12, 15:03

i tried it, it dosnt work too. It looks strange but both ways don't work.Just guessing but might it be becouse of types of data? (ie int and text?) - user891908

Yes, that matters too. Check if agemin is an integer. - UltraInstinto

Thrustmaster: Thank you, agemin was passed as text value and 'i' was integer - user891908

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.