I use django_tables2 to render my tables. For one table, I only want to see the most recent 5 entries. Therefore, I need to order my queryset before passing it to the table object:
qset = myObject.objects.order_by('-start_time').all()[:5]
table = MyTableClass(qset, template='path/to/template.html')
This yields the following error message:
AssertionError: Cannot reorder a query once a slice has been taken.
I could set orderable=False
for every django_tables.Column
, but since MyTableClass inherits from another table class, I would like to avoid this.
Thanks in advance
table = MyTable(data, orderable=False)
will disable ordering for a table. This takes precedence over any value set in theclass Meta.orderable
attribute. – Acrylic