I found a link to have a 'switch' tag in Django templates, but I was wondering if this can be somehow achieved without it. Using only the stuff which comes with Django? Basically is there other way then using multiple 'if' or 'ifequal' statements?

To the previous responders: Without understanding the use case, you've made assumptions and criticized the questioner. @Ber says "all over the place" which is certainly not implied by the questioner. Not fair.

I have a case where I would like to do a {%switch%} statement in exactly one place in my Django template. Not only is it not convenient to move the equivalent of the switch statement into Python code, but that would actually make both the view and the template harder to read and take simple conditional logic that belongs in one place and split it into two places.

In many cases where I could imagine a {%switch%} (or an {%if%}) being useful, not using one requires putting HTML in a view. That's a far worse sin and is why {%if%} exists in the first place. {%switch%} is no different.

Fortunately, Django is extensible and multiple people have implemented switch. Check out: