Commit 1d72cc06 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

correct pagination with filters on using custom tag

custom tag copied from https://stackoverflow.com/a/17068299


Former-commit-id: 7fc0c4824eb0d75e0f4b01d3589cba92f6af490d
parent 035e1889
{% extends "base.html" %}
{% load customtags %}
{% block title %}compound{% endblock %}
......@@ -46,7 +46,7 @@
<ul class="pagination justify-content-end">
{% if compounds.has_previous %}
<li class="page-item">
<a class="page-link" href="?page={{ compounds.previous_page_number }}" tabindex="-1">Previous</a>
<a class="page-link" href="?{% url_replace request 'page' compounds.previous_page_number %}" tabindex="-1">Previous</a>
</li>
{% endif %}
......@@ -56,7 +56,7 @@
{% if compounds.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ compounds.next_page_number }}" tabindex="-1">Next</a>
<a class="page-link" href="?{% url_replace request 'page' compounds.next_page_number %}" tabindex="-1">Next</a>
</li>
{% endif %}
</ul>
......
from django import template
register = template.Library()
@register.simple_tag
def url_replace(request, field, value):
dict_ = request.GET.copy()
dict_[field] = value
return dict_.urlencode()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment