Using filters through the django-filter module

Please tell me what am I missing. It is necessary to implement a table search in several columns as in the screenshot.[enter image description here][1] [1]: https://i.stack.imgur.com/1Zzw1.png. There is a video on YouTube with the implementation, but through the functions.

<div class="row">
    <div class="col">
        <div class="card card-body">
            <form method="get">
                    {{tableFilter.form}}
                <button class="btn btn-primary" type="submit">
                    Поиск
                </button>
            </form>
        </div>
    </div>
</div>

views.py

class Home(ListView):
model = Reports
template_name = 'gaz_app/index.html'
context_object_name = 'Reports'
paginate_by = 20

def get_context_data(self, *, object_list=None, **kwargs):
    context = super().get_context_data(**kwargs)
    context['title'] = 'ИС'
    return context

def seacrh_filter(request):
    customer = Reports.objects.all()
    orders = Reports.order_set.all()
    context = {'orders': orders}
    tableFilter = OrderFilter(queryset=orders)
    orders = tableFilter.qs
    return render(request, 'gaz_app/index.html', context)

filters.py

class OrderFilter(django_filters.FilterSet):
# минимум 2 атрибута
class Meta:
    model = Reports  # Модель для которой мы создаем фильтр
    fields = ['facility', 'structural_unit']  # Указываем какие поля мы хотим разрешить

urls.py

urlpatterns = [
path('', Home.as_view(), name='home'),
path('structural_unit/<str:pk>/', ReportByStructuralUnit.as_view(), name='structural_unit'),
path('report/<str:pk>/', GetReport.as_view(), name='report'),

]

models.py

class Reports(models.Model):
"""Отчеты"""
short_title = models.CharField(max_length=150, verbose_name='Краткое название')
comment = models.TextField(blank=True, verbose_name='Комментарий')
facility = models.ForeignKey('Facility', on_delete=models.PROTECT, verbose_name='Объект')
structural_unit = models.ForeignKey('StructuralUnit', on_delete=models.PROTECT,
                                    verbose_name='Структурное подразделение')
executor = models.ForeignKey('Executor', on_delete=models.PROTECT, verbose_name='Исполнитель')
surveys = models.ForeignKey('Surveys', on_delete=models.PROTECT, verbose_name='Вид исследования')
file = models.FileField(upload_to='Отчеты объектов', verbose_name='Отчет для загрузки')
year_of_work = models.DateField(verbose_name='Отчетный период')
date_of_download = models.DateTimeField(auto_now_add=True, verbose_name='Дата загрузки')

def __str__(self):
    return self.short_title

def get_absolute_url(self):
    return reverse('report', kwargs={"pk": self.pk})

class Meta:
    verbose_name = 'Отчет'
    verbose_name_plural = 'Отчеты'
    ordering = ['-year_of_work']
Back to Top