Sign up ×  Im getting strangest error in django so far:  'if'
statement improperly formatted  Template that raises the error
is this:  {% if diff >= 0 %} <span class="pos">+{{ diff }} {%
else %} <span class="neg">-{{ diff }} {% endif %} <span>{{ a
}}</span>  view that has a and diff in context is this:  def
add(request, kaart_id):     if request.is_ajax() and
request.method == 'POST':         x =
Kaart.objects.get(id=kaart_id)         x.pos += 1         x =
Kaart.objects.get(id=kaart_id)                       from
django.utils import simplejson         diff = x.pos - x.neg
a = "(+1)"         context = { 'diff':diff, 'a':a }
return render_to_response('sum.html', context,
context_instance=RequestContext(request))  It does not matter
what equation i use in if, >, >=, ==.. they all raise the same
error.  and as far as i can tell its all by the book:
share|improve this question  4 Answers 4  up vote 7 down vote
accepted  Until Django 1.2 lands you are looking for "Smart If",
a Django Template Tag.  A smarter {% if %} tag for django