Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not parse the remainder

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

like image 339
LoveTW Avatar asked Aug 25 '10 02:08

LoveTW


People also ask

What does could not parse the remainder mean?

This error usually means you've forgotten a closing quote somewhere in the template you're trying to render. For example: {% url 'my_view %} (wrong) instead of {% url 'my_view' %} (correct). In this case it's the colon that's causing the problem. Normally you'd edit the template to use the correct {% url %} syntax.

Could not parse the remainder Django template error?

But if you look at it carefully, you will think the error message is very helpful and clear TemplateSyntaxError: Could Not Parse The Remainder. The error is because of the Django static tag's argument 'css/dept_emp_style. css', the single quote( ' ) is not an English character. Instead, it is a Chinese character.

What is Django template language?

A Django template is a text document or a Python string marked-up using the Django template language. Some constructs are recognized and interpreted by the template engine. The main ones are variables and tags. A template is rendered with a context.


2 Answers

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 %}
like image 58
Ned Batchelder Avatar answered Sep 23 '22 05:09

Ned Batchelder


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' %}">
like image 38
DevB2F Avatar answered Sep 23 '22 05:09

DevB2F