Django template ifequal - request GET and object id
Why is t开发者_StackOverflow社区his not the same??
{% ifequal gender.id request.GET.gender %} {{gender.name}} {% endifequal %}
gender.id = 1 request.GET.gender = 1
Please help, I think it's simple :)
If you are using django > 1.0 you might try
{% ifequal gender.id|stringformat:"s" request.GET.gender %}....{% endifequal %}
Or using d to have an decimal integer
{% ifequal gender.id request.GET.gender|stringformat:"d" %}....{% endifequal %}
Reference: http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#stringformat
Okay!, I updated my Django version from - 1.0.2 to 1.2.1
WOOP
Now it worked ;)
gender.id|stringformat:"s"
Thank you all for the advice ;)
精彩评论