I've attached a piece of code to you to modify it according to your code.
View
class ProductoFiltrar(FilterView):
model = Producto
filterset_class = ProductoFilter
paginate_by = '50'
is_paginated = True
def get_context_data(self, **kwargs):
context = super(ProductoFiltrar, self).get_context_data(**kwargs)
parametros = self.request.GET.copy()
if parametros.get('page') != None:
del parametros['page']
context['parametros'] = parametros
return context
Template
{% if is_paginated %}
<ul class="pagination">
{% if page_obj.has_previous %}
<li>
<span><a href="?page={{ page_obj.previous_page_number }}{% if parametros.urlencode %}&{{ parametros.urlencode }}{% endif %}">Anterior</a></span>
</li>
{% endif %}
<li class="">
<span>Página {{ page_obj.number }} de {{ page_obj.paginator.num_pages }}.</span>
</li>
{% if page_obj.has_next %}
<li>
<span><a href="?page={{ page_obj.next_page_number }}{% if parametros.urlencode %}&{{ parametros.urlencode }}{% endif %}">Siguiente</a></span>
</li>
{% endif %}
</ul>
{% endif %}
This will copy the filter parameters and remove the page parameter to overwrite it with the new page.
FilterView
is a class of a library called django-filter
, as I do not know how you have created your view I attached the library. django-filter