Could not parse the remainder: '==obj.id' from 'sobj.id==obj.id'

Viewed 121

i am using nested for loop in django template to print data which i get from the data base

            {% if objectives %}
            {% for obj in objectives %}
            {% for sobj in sobjective %}
            {% if sobj.id==obj.id %} yes {% endif %}

all the open tags are closed

but its raising an error as i mentioned above

TemplateSyntaxError at /objectives
Could not parse the remainder: '==obj.id' from 'sobj.id==obj.id'
1 Answers

The Django template language requires spaces around the == operator, so you should implement this as:

{% if sobj.id == obj.id %} yes {% endif %}

In Python x==y would be valid, but Django's template language has specific tokens and grammar.

Related