我是使用Python进行编程的新手。我想将分页与过滤器结合起来,但是我发现的解决方案对我不起作用。这是我的观点
views.py
@login_required
def publication_list(request):
f = PublicationFilter(request.GET, queryset=Publication.objects.all())
return render(request, 'info/filter.html', {'filter':f})
filter.py
from registration.models import Publication
import django_filters
class PublicationFilter(django_filters.FilterSet):
user__username = django_filters.CharFilter(lookup_expr='icontains', label='Nombre de usuario')
title = django_filters.CharFilter(lookup_expr='icontains', label='Titulo')
class Meta:
model = Publication
fields = [
'user__username', 'title', 'estatus',
]