Почему мой фильтр django отображается, но не работает?
Я использую фильтры Django. Сначала он работает правильно, но когда я добавил часть пагинации, он больше не работает. Любая помощь будет оценена по достоинству. Заранее благодарю за помощь!
Вот мой views.py
views.py
def house(request):
house=t_house.objects.all()
house_paginator=Paginator(house,10)
page_num=request.GET.get('page')
page=house_paginator.get_page(page_num)
houseFilter=HouseFilter(request.GET, queryset=house)
house=houseFilter.qs
context={
'count':house_paginator.count,
'page':page,
'houseFilter':houseFilter
}
return render(request, 'accounts/house.html', context)
Вот мой filters.py
filters.py
class HouseFilter(django_filters.FilterSet):
class Meta:
model=t_house
fields=['c_acronym']
и вот мой html файл
house.html
<div class="card card-body">
<h2>Total: {{ count }}</h2>
<a class="btn btn-primary btn-sm btn-block" href="{% url 'create_house' %}">Create House</a>
<div class="p-2 bg-white shadow-sm d-flex justify-content-around align-items-center rounded">
<form method="get">
{{houseFilter.form}}
<button class="btn btn-primary" id="mainfont" type="submit">Search</button>
</form>
</div>
<table id="dtBasicExample" class="table table-striped table-bordered table-sm" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Code</th>
<th>Model</th>
<th>Acronym</th>
</tr>
</thead>
{% for h in page.object_list %}
<tr>
<td><a class='btn btn-sm btn-info' href="{% url 'house_details' h.id %}">View</a></td>
<td>{{h.c_code}}</td>
<td>{{h.c_model}}</td>
<td>{{h.c_acronym}}</td>
<td><a class='btn btn-sm btn-info' href="{% url 'update_house' h.id %}">Update</a></td>
<td><a class='btn btn-sm btn-danger' href="{% url 'delete_house' h.id %}">Remove</a></td>
</tr>
{% endfor %}
</table>
<nav aria-label="...">
<ul class="pagination justify-content-center">
<li class="page-item">
{% if page.has_previous %}
<a class="page-link" href="{% url 'house' %}?page={{ page.previous_page_number }}">Previous</a>
{% endif %}
</li>
<li class="page-item">
{% if page.has_next %}
<a class="page-link" href="{% url 'house' %}?page={{ page.next_page_number }}">Next</a>
{% endif %}
</li>
</ul>
</nav>
</div>