In my home page I have blog, on the right side there is Posts category list like:
- Sports
- Crime
and etc.. I try to make that when I'm in certain category that active category button will be highlighted. I'm doing that by setting GET parameter to my home page like: /?category=1
NOW... In index.html template I'm doing this:
{% for category in category_list %}
{{ category.pk }} != {{ request.GET.category }} // This is for debugging. Returns 1==1
{% if category.pk == request.GET.category %}
<li><a href="{% url 'web_serv:index' %}?category={{ category.pk }}">{{ category }}<span class="pull-right">({{ category.post_set.count }})</span></a></li>
{% else %}
<li class="active"><a href="{% url 'web_serv:index' %}?category={{ category.pk }}">{{ category }}<span class="pull-right">({{ category.post_set.count }})</span></a></li>
{% endif %}
{% endfor %}
But this is not working. Any suggestions how to solve this, maybe there is another way?
EDITED:
I figured that category.pk returns int and request.GET.category returns string. Next question. How to convert int<==>string, so I could compare them?