Wednesday, September 29, 2010

Something breaking if tag

I have in my template the following:

{% if subtopic.id == selected_id %}...{% endif %}

subtopic.id is being pulled from a list of subtopics that I'm looping
over.

selected_id is being sent to the template by the view after some form
processing:
#views.py
selected_id = request.GET.get('subtopic', '')
...

For some reason, my {% if %} statement in the template isn't getting
evaluated even when the values of both subtopic.id and selected_id are
the same. It does, however, work properly if I do the following before
I send selected_id to the template:
#views.py
selected_id = int(selected_id)

Why is this? I'm wondering.

Thanks in advance for any insight.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment