Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paginate template tag not thread safe #82

Open
baskoopmans opened this issue Jan 20, 2015 · 0 comments
Open

Paginate template tag not thread safe #82

baskoopmans opened this issue Jan 20, 2015 · 0 comments

Comments

@baskoopmans
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant