Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 513125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:23:25+00:00 2026-05-13T07:23:25+00:00

Im getting strangest error in django so far: ‘if’ statement improperly formatted Template that

  • 0

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>
<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.save
        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: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#id5

Alan.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:23:25+00:00Added an answer on May 13, 2026 at 7:23 am

    Until Django 1.2 lands you are looking for “Smart If”, a Django Template Tag.

    A smarter {% if %} tag for django
    templates.

    While retaining current Django functionality, it also handles
    equality,
    greater than and less than operators. Some common case examples::

        {% if articles|length >= 5 %}...{% endif %}
        {% if "ifnotequal tag" != "beautiful" %}...{% endif %}
    

    Arguments and operators must have a space between them, so
    {% if 1>2 %} is not a valid smart if tag.

    All supported operators are: or, and, in, = (or
    ==), !=, >, >=, < and <=.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When using passenger the actual user is nobody so one… May 16, 2026 at 11:54 am
  • Editorial Team
    Editorial Team added an answer the solution is in this thread. check this May 16, 2026 at 11:54 am
  • Editorial Team
    Editorial Team added an answer Yes, you can manipulate Google Maps through jQuery. Actually, there… May 16, 2026 at 11:54 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm getting a strange error that only occurs on the live server. My Django
We have a button that saves asynchronously using AjaxToolKit/C#/.NET. I'm getting this in my
Im getting this error when I try and make an object. Here is my
Im getting that error when try to call a __doPostBack on one of my
I'm getting a fatal PHP error when trying to execute my script: Using $this
I'm getting a strange error and can't figure out why. I'd appreciate any input.
This is the strangest most unexplainable and frustratng thing I've experienced with flash and
Sigh I keep getting strange problems with IE 8. I have this <input name=Btn_Edit
Getting a NSString as follows: NSString *lastSyncDate = [[items objectAtIndex:0] objectForKey:@LastSyncDate]; This value is:
I am deploying my django application on a server, and on last stages I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.