Fixed bug that removes the filter in the expenses list when the page is changed
This commit is contained in:
parent
219a0a5a36
commit
8d64673114
@ -144,17 +144,17 @@
|
||||
</table>
|
||||
|
||||
<div class="pagination">
|
||||
<span class="step-links">
|
||||
<span class="step-links">
|
||||
{% if page_obj.has_previous %}
|
||||
<a href="?page=1{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">« Primero</a>
|
||||
<a href="?page={{ page_obj.previous_page_number }}{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">Anterior</a>
|
||||
<a href="?page=1{% if query_params %}&{{ query_params }}{% endif %}">« Primero</a>
|
||||
<a href="?page={{ page_obj.previous_page_number }}{% if query_params %}&{{ query_params }}{% endif %}">Anterior</a>
|
||||
{% endif %}
|
||||
|
||||
<span>Página {{ page_obj.number }} de {{ page_obj.paginator.num_pages }}</span>
|
||||
|
||||
{% if page_obj.has_next %}
|
||||
<a href="?page={{ page_obj.next_page_number }}{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">Siguiente</a>
|
||||
<a href="?page={{ page_obj.paginator.num_pages }}{% if selected_year %}&year={{ selected_year }}{% endif %}{% if selected_month %}&month={{ selected_month }}{% endif %}{% if selected_category %}&category={{ selected_category }}{% endif %}{% if selected_tag %}&tag={{ selected_tag }}{% endif %}">Último »</a>
|
||||
<a href="?page={{ page_obj.next_page_number }}{% if query_params %}&{{ query_params }}{% endif %}">Siguiente</a>
|
||||
<a href="?page={{ page_obj.paginator.num_pages }}{% if query_params %}&{{ query_params }}{% endif %}">Último »</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from operator import truediv
|
||||
from datetime import date, datetime
|
||||
from django.contrib import messages
|
||||
from django.template import context
|
||||
from .models import Account, Category, Expense, FuelEntry, Tag, Income
|
||||
from .forms import ExpenseForm, IncomeForm, TagForm, AccountForm, FuelEntryForm, CategoryForm
|
||||
# from dateutli.relativedelta import relativedelta
|
||||
@ -156,7 +157,10 @@ def expense_list(request):
|
||||
# Pagination
|
||||
paginator = Paginator(expenses, 10)
|
||||
page_number = request.GET.get('page')
|
||||
page_obj = paginator.get_page(page_number)
|
||||
page_obj = paginator.get_page(page_number)
|
||||
|
||||
query_params = request.GET.copy()
|
||||
query_params.pop('page', None)
|
||||
|
||||
# tags with state
|
||||
tags_with_state = []
|
||||
@ -203,7 +207,8 @@ def expense_list(request):
|
||||
'tags_with_state': tags_with_state,
|
||||
'accounts': Account.objects.filter(owner=request.user),
|
||||
'selected_account': account_id,
|
||||
'advanced_filters_open' : advanced_filters_open
|
||||
'advanced_filters_open' : advanced_filters_open,
|
||||
'query_params': query_params.urlencode(),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user