Reputation: 5993
I asked what was wrong with my conditionals in What is wrong with my Django templating use of if's? and so far every response has been, "Here's how you can code more pythonically for the specimen I gave. What they did not do is even hint at why my conditional was wrong and could be improve.
"{% if ":" not in url.url %}" and "{% if time_zone.0 == entity.time_zone %}" are both getting "'if' statement improperly formatted" errors. What is this? How can I adjust the conditionals so that they don't crash.
Upvotes: 0
Views: 82
Reputation: 6069
This is just a guess, but it sounds like you might be using an older version of Django (<1.2) where these constructs are not yet supported. In Django <1.2, you'd have to use (for example) {% ifequal time_zone.0 entity.time_zone %}
instead of {% if time_zone.0 == entity.time_zone %}
.
If this is indeed the problem, you could upgrade Django if that's possible, or you could use this smartif templatetag, which implements comparison operations as in Django >= 1.2. That link includes instructions for how to use it. You might need to do a custom filter or another approach to get the not in
functionality though, because it doesn't look like smart_if implements that.
Upvotes: 3