Reputation: 5514
I know that I can change the order of attributes in my model class definition to change the order of (non-excluded) table columns. Specifically, how do I insert a TemplateColumn in the second column instead of in the last column? My read through the documentation shows every instance of 'sort' and of 'order' that I could find seems to apply to the rows of the table, not the columns.
Here's what I have:
import django_tables2 as tables
class EntryTable(tables.Table):
concept = tables.TemplateColumn(template_name='simplelist/entry_detail_link.html')
class Meta:
model = Entry
exclude = ('id','list',)
attrs = {"class": "paleblue"}
and that template is really just the text of the record and the link to the detail page:
<a href="{% url 'simplelist:entry_detail' record.pk %}">{{record.concept_name}}</a>
And of course I needed a view and a template to display the table, but I got that working by pretty much following the docs so I'll spare you that unless it's needed. This seems basic so I cannot believe I'm not finding it, but perhaps I'm tripping over all the information on how to sort/order the rows of the table. ...but my vision is blurring, so perhaps I'm overdue for sleep.
Upvotes: 0
Views: 685
Reputation: 6790
By using sequence
:
class EntryTable(tables.Table):
concept = tables.TemplateColumn(template_name='simplelist/entry_detail_link.html')
class Meta:
model = Entry
exclude = ('id','list',)
attrs = {"class": "paleblue"}
sequence = ("entry_field_1", "concept", "...")
Upvotes: 2