views:

35

answers:

2

Why is this 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 :)

A: 

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

ee_vin
Hey, I use django 1.0I have tried gender.id|stringformat:"s" with no luck :( ..
pkdkk
When i print request.GET.id|stringformat:"d" to the template, it's empty, and it still not work :(
pkdkk
Do you have 'django.core.context_processors.request' in TEMPLATE_CONTEXT_PROCESSORS inside your settings.py? http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request
ee_vin
Yep, request.GET.gender is 1 in the template... So i dont get i why i can't compare the to values :(
pkdkk
hey I made a typo ;) try request.GET.gender|stringformat:"d"
ee_vin
I already had tried that - {% ifequal gender.id request.GET.gender|stringformat:"d" %} {{gender.name}} {% endifequal %}I won't work :(
pkdkk
A: 

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 ;)

pkdkk