I'm trying to add a filter feature in my django-tables 2
so I opted for django-filter
. I followed the documentation it worked great but I don't know how to integrate it with django-tables 2
.
I made a filter class and in the view i made something like this :
queryset = Fitzroyfalls.objects.select_related().all()
f = FitzroyfallsFilter(request.GET, queryset=queryset)
table = FitsroyFallsTable(f.queryset)
table.paginate(page=request.GET.get('page', 1), per_page=25)
RequestConfig(request).configure(table)
return render(request, 'query.html', {'table': table})
but nothing happens, it only displays the table with all data.
After hours of trying, I got the solution which is simple. In the view add those lines :
if request.method == "GET"
list1=list()
for obj in f:
list1.append(obj)
table=FitsroyFallsTable(list1)
aaand that's it !