Hi all. i have a problem with django-filter and pagination. Probably someone can help me
when i use filter and click submit button, the url looks like this.
http://127.0.0.1:8000/catalog/yarns_filter/?color=grey&stockable=1
and pagination looks like this
Page 1 of 2. next
on this step everthing looks ok
but if i click next link, url looks like this
http://127.0.0.1:8000/catalog/yarns_filter/?page=2
Now pagination ignores filter
code in template looks like this
<form action="" method="get">
{{ filter.form.as_p }}
<input type="submit" />
</form>
{% if events.object_list %}
{% for product in events.object_list %}
<div class="col-sm-6 col-md-3">
<div class="thumbnail">
{% if product.image %}
<img src="{{ product.image.url }}" />
{% else %}
<img src="{% static 'main/img/noimage.jpg' %}" />
{% endif %}
<div class="caption">
<h3>Номер по каталогу: {{ product.catalog }}</h3>
<p>Арт: {{ product.sku }}</p>
<p>Рал: {{ product.rall }}</p>
<p>Цвет: {{ product.color.template_name }}</p>
{% if product.type %}
{% if product.type == 'syntetic' %}
<p>Синтетическая</p>
{% else %}
<p>Хлопковая</p>
{% endif %}
{% endif %}
{% if product.stockable %}
<p><span class="label label-success">Складская позиция</span></p>
{% else %}
<p><span class="label label-danger">Под заказ</span></p>
{% endif %}
</div>
</div>
</div>
{% endfor %}
{% else %}
<h3><span class="label label-default">Ничего не найдено</span></h3>
{% endif %}
and pagination
<div class="pagination">
<span class="step-links">
{% if events.has_previous %}
<a href="?page={{ events.previous_page_number }}">previous</a>
{% endif %}
<span class="current">
Page {{ events.number }} of {{ events.paginator.num_pages }}.
</span>
{% if events.has_next %}
<a href="?page={{ events.next_page_number }}">next</a>
{% endif %}
</span>
</div>
so WTF? =)
четверг, 18 апреля 2013 г., 21:27:56 UTC+3 пользователь Andy Warburton написал: