Search code examples
django-tables2

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


In views.py the view table view is defined

    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

Then in my template I call the table title like this:

    <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>

Solution

  • I eventually gave up on this issue and instead used

    {{ request.resolver_match.url_name }}
    

    in my template instead. Although not an optimal solution it certainly was acceptable for my needs.