[Django]-Could not parse the remainder

61👍

Inside a {% %} tag, variables aren’t surrounded by {{. Try this:

{% ifequal num buildSummary_list.number %}

Also, it looks like your two comparisons can be joined with an else:

{% for num in buildSummary_list.paginator.page_range %}
    {% ifequal num buildSummary_list.number %}
        <b>{{num}}</b>
    {% else %}
        <a href="?page={{num}}"><b>{{num}}</b></a>
    {% endifequal %}
{% endfor %}

19👍

I got this error when I forgot the ” around the path to a static file

This gave the error:

 <link rel='stylesheet' href="{% static css/style.css %}">

This fixed the error:

 <link rel='stylesheet' href="{% static 'css/style.css' %}">
👤DevB2F

1👍

The django. DjangoTemplates template backend is unable to parse a comparison operator when there is no whitespace around the operator using builtin tag if:

{% if foo=='bar' %}
<!-- do something -->
{% endif %}

raises
TemplateSyntaxError at url

Could not parse the remainder: ‘==’bar” from ‘foo==’bar”

At least one space is required on both sides of the == operator (So foo ==’bar’ and foo== ‘bar’ throws Could not parse the remainder: ‘==’bar” from ‘==’bar” and Could not parse the remainder: ‘==’ from ‘foo==’, respectively). More than one space is acceptable.
This seems to affect the following boolean operators: ==, !=, <, >, <=, >=. My guess is the boolean expression tokenizer in DjangoTemplates first tries split(‘ ‘) then ultimately evals [0][1][2] (but I haven’t actually looked at the source to verify this).

1👍

thats so easy you should not write like this

{% if foo=='bar' %}
<!-- do something -->
{% endif %}

you should write your code like this

{% if foo == 'bar' %}
<!-- do something -->
{% endif %}

pay attention to the space before ==

1👍

When you are dealing with comparison operator == within templates, make sure you have spaces before and after == operator. This could be one of the reason for above error.
For ex. category.slug == c.slug

0👍

django 2.2 relative URL

**Correct**

<a href="{% url 'urlapp:other' %}">go to other page </a>
<br/>
<a href="{% url 'admin:index' %}"> admin page</a>

**error inccorect code some white space still get same error ** 

<a href="{% url 'urlapp:other' %}">go to other page </a>
<br/>
<a href="{% url 'urlapp: other' %}">go to other page </a>
<br/>
<a href="{% url 'admin:index' %}"> admin page</a>
<br/>
<a href="{% url 'admin':index %}"> admin page</a>

0👍

Could not parse the remainder: ‘>0’ from ‘forloop.counter>0’

I got this error !!!

if its a TemplateSyntaxError then just correct your spaces between the code
For example:

( wrong statement ) {% if forloop.counter|divisibleby:3 and forloop.counter>0 and not forloop.last %}

( right statement ) {% if forloop.counter|divisibleby:3 and forloop.counter > 0 and not forloop.last %}
space between ( forloop.counter > 0)

this worked for me

Leave a comment