正确的行数,但它们是空的

Right number of rows, but they're empty

我正在尝试显示一些 table,但它们是空的。得到我的部分是行数是正确的,但它们完全是空白的。如果 table 有 9 个条目,我得到 9 个空行。

相同的代码适用于不同的 table

tables.py:

class VouchersTable(tables.Table):
    class meta:
        model = Vouchers
        fields = ('event_name', 'pk', 'valid_start', 'valid_end', 'lab_duration', 'user_email', 'redeem_date' )

views.py:

class ReportsView(LoginRequiredMixin, TemplateView):
    template_name = 'reports.html'

    def get_context_data(self, **kwargs):
        context = super(ReportsView, self).get_context_data(**kwargs)
        vouchers = VouchersTable(Vouchers.objects.all())
        RequestConfig(self.request, paginate=False).configure(vouchers)
        context['vouchers'] = vouchers

        return context

reports.html:

{% extends "base.html" %}
{% load render_table from django_tables2 %}

{% block content %}
  {% render_table vouchers %}
{% endblock content %}

models.py:

class Vouchers(models.Model):
    creator_uid = models.IntegerField()
    user_id = models.IntegerField()
    username = models.CharField(max_length=255)
    user_email = models.CharField(max_length=100)
    event_name = models.CharField(max_length=255)
    event_code = models.IntegerField()
    valid_start = models.IntegerField()
    valid_end = models.IntegerField()
    redeemed = models.IntegerField()
    redeem_date = models.IntegerField()
    lab_version = models.CharField(max_length=40)
    lab_model = models.IntegerField()
    lab_id = models.IntegerField()
    lab_duration = models.IntegerField()

结果 html(删除空行):

<div class="table-container">
<table>
    <thead>
        <tr>
        </tr>
    </thead>
    <tbody> 
        <tr class="even">
        </tr>
        <tr class="odd">
        </tr>
        <tr class="even">
        </tr>
        <tr class="odd">
        </tr>
        <tr class="even">
        </tr>
        <tr class="odd">
        </tr>
        <tr class="even">
        </tr>
        <tr class="odd">
        </tr>
        <tr class="even">
        </tr>
    </tbody>
</table>
</div>

哦好吧... 您已这样声明 table:

class VouchersTable(tables.Table):
    class meta:
        model = Vouchers
        fields = ('event_name', 'pk', 'valid_start', 'valid_end', 'lab_duration', 'user_email', 'redeem_date' )

正确的写法是class MetaMeta,M大写):https://github.com/jieter/django-tables2