当我在一个视图中设置 table 标题时,我有三个 table 视图都是 django-table2,每个视图都会更改

I have three table views all django-table2 when I set the table title in one view it is changed for each view

在views.py视图table中定义了视图

    class CompletedClassList(SingleTableMixin, FilterView):
        table_class = ClassTable
        table_class.title='Completed Classes'
        filterset_class = ClassFilter
    
        template_name = "classes/class_list.html"
        table_pagination = {"per_page": 20}
    
            def get_queryset(self):
                today = datetime.date.today()
                completed_classes = Class.objects.filter(class_start_date__lte=today)
                return completed_classes

然后在我的模板中,我这样调用 table 标题:

    <div class="row col=md-12 may-form-space">
       <div class="col-md-3 text-md-left">
           <label class="may-form-section">{{ table.title }}</label>
       </div>
    </div>

我最终放弃了这个问题,转而使用

{{ request.resolver_match.url_name }}

在我的模板中。虽然不是最佳解决方案,但它肯定可以满足我的需求。