Could not parse the remainder

Viewed 120943

i want to compare num and {{buildSummary_list.number}}, but why it is not work? And i got an error

Could not parse the remainder: '{{buildSummary_list.number}}' from '{{buildSummary_list.number}}'"...

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

{% endfor %}

I want to make the pagination have effect: pre << 1 2 3 4 5 6 >> next

I my code can run, can it make this effect? thanks:D

5 Answers
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>

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

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).

Related