Python 在django-tables2表中呈现django简单历史查询

Python 在django-tables2表中呈现django简单历史查询,python,django,django-tables2,django-simple-history,Python,Django,Django Tables2,Django Simple History,我尝试在django-tables2表中呈现django简单历史queryset。此时,我将原始查询集传递给上下文中的模板。此外,我想将Queryset传递给表对象,以使用表的功能,如linkyfy列或exclude列。为此,我必须在meta表中指定一个模型。这里的问题是,历史的模型是自动生成的 实际代码: #views.py from .tables import HistoryTable class HistoryView(LoginRequiredMixin, SingleTableVi

我尝试在
django-tables2
表中呈现
django简单历史
queryset。此时,我将原始查询集传递给上下文中的模板。此外,我想将Queryset传递给
对象,以使用表的功能,如linkyfy列或exclude列。为此,我必须在meta表中指定一个模型。这里的问题是,历史的模型是自动生成的

实际代码:

#views.py
from .tables import HistoryTable

class HistoryView(LoginRequiredMixin, SingleTableView):
    template_name = "funkwerkstatt/history.html"

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context["table"] = Device.history.filter(id=self.kwargs["pk"])
        ## futur code
        #context["table"] = HistoryTable(Device.history.filter(id=self.kwargs["pk"]))
        return context

#tables.py
import django_tables2 as tables

class HistoryTable(tables.Table):
    device = tables.Column(accessor="device", linkify=True)
    class Meta:
        model = # HistoryModel?!
        empty_text = "No entry"
        exclude = ["id",]

是否有方法引用自动生成的
HistoryModel

阅读文档有时会有所帮助

class PollHistoryListView(ListView): # or PollHistorySerializer(ModelSerializer):
    class Meta:
        model = Poll.history.model
       # ...