That would be my guess. I presume that item.id is an int, so it's likely that you're passing berufe_id as a string. All the stuff that comes from the GET or POST attributes or request, and any arguments garnered by the url pattern are strings. If you're not converting it yourself, berufe_id will be a string, and:
>>> 1 == '1' False >>> Do you have a view function, or are you fitting this into a generic view somehow? Too bad that there doesn't seem to be a filter to invoke the int constructor, or a string method that does it. You could add a method to your model that returns id as a string, then ...{% ifequal item.id_as_string berufe_id %}... On Wed, Mar 10, 2010 at 10:23 AM, wolle <wo...@upb.de> wrote: > Already tried this several times. Here is a result of your code > > item.id = 1 with berufe_id = 1 > item.id = 2 with berufe_id = 1 > > Not sure if this a type (int vs. string) error? > > On Mar 10, 4:18 pm, Bill Freeman <ke1g...@gmail.com> wrote: >> Try adding code to render the values that you are trying to compare, >> so that you can see in what way they are not equal. They it will >> probably become obvious in what way the conversion through the >> GET or POST data and view isn't quite what you want. E.g.; before >> the select: >> >> <p>berufe_id: {{ berufe_id }}</p> >> <ul>{% for item in berufe %}<li>{{ item.id }}</li>{% endfor %}</ul> >> >> On Wed, Mar 10, 2010 at 8:01 AM, wolle <wo...@upb.de> wrote: >> > Hi everybody, >> >> > I have a question on the ifequal template tag. >> >> > I have an HTML select where people can filter the database entries. On >> > change of the selection I reload the page (new URL) and filter the >> > results. I append the selected value from the option to the request >> > (as berufe_id) and want to pre-select the chosen option with the >> > following code: >> >> > <select name="berufe" id="berufe" onchange="onSubmitFilterForm();"> >> > <option value="0">-- Please select >> > --</option> >> > {% for item in berufe %} >> > <option value="{{item.id}}" {% >> > ifequal item.id berufe_id %} >> > selected{% endifequal %}>{{item.name}}</option> >> > {% endfor %} >> > </select> >> >> > Somehow the equal check does not work. item.id is the id of the Object >> > iterator and berufe_id the selected value from the last selection... >> > {% ifequal item.id "2" %}selected{% endifequal %} seems to work >> > though... >> >> > Who can help me with this? >> >> > Thanks >> > Wolle >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "Django users" group. >> > To post to this group, send email to django-us...@googlegroups.com. >> > To unsubscribe from this group, send email to >> > django-users+unsubscr...@googlegroups.com. >> > For more options, visit this group >> > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.