Could not parse the remainder

孤人 提交于 2020-06-09 11:58:07

问题


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


回答1:


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 %}



回答2:


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' %}">



回答3:


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>


来源:https://stackoverflow.com/questions/3562559/could-not-parse-the-remainder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!