frankban / django-endless-pagination

This project is deprecated: please use https://github.com/shtalinberg/django-el-pagination
MIT License
251 stars 108 forks source link

Paginate template tag not thread safe #82

Open baskoopmans opened 9 years ago

baskoopmans commented 9 years ago

If ?poll_page=5 and article_page is not set both polls and articles pagination have page 1 active and poll has page 5 activated (as expected).

{% paginate polls_queryset using "poll_page" %} {% include "pagination.html" %} {% paginate articles_queryset using "article_page" %} {% include "pagination.html" %}

pagination.html

{% get_pages %}
{{ pages.current.number }}
{% if pages.paginated %}
  <nav>
    <ul class="pagination">
      {% for page in pages %}
        {{ forloop.counter }}
        {% if page.is_first and not page.is_current %}
          <li>
            <a href="{{ pages.previous.url }}" aria-label="Previous">
              <span aria-hidden="true">&laquo;</span>
            </a>
          </li>
        {% endif %}
    <li{% if pages.current.number == page.number %} class="active"{% endif %}>{{ pages.current.number }}<a href="{{ page.path }}">{{ page.number }}</a></li>
    {% if page.is_last and not page.is_current %}
      <li>
        <a href="{{ pages.next.url }}" aria-label="Previous">
          <span aria-hidden="true">&raquo;</span>
        </a>
      </li>
    {% endif %}
  {% endfor %}
</ul>
</nav>
{% endif %}

https://docs.djangoproject.com/en/1.7/howto/custom-template-tags/#thread-safety-considerations