extra_columsを使用しようとしてもエラーは発生しませんが、テーブルは表示されません。私はhereのドキュメントを使用しました。私はテーブルにチェックボックスを持つ列を追加しようとしています。私は既にテーブルをあらかじめ定義していて、いくつかのフィールドを除外することができますが、ドキュメントを使って新しいカラムを追加する方法を理解することはできません。私は何かが欠けている必要がありますdjango_tables2.tables.Tableでextra_columnsを使用する
実装は以下で見ることができます。助けていただければ幸いです。 VIEW
from project.tables import ProjectTable
from django_tables2.columns import CheckBoxColumn
class AllocationChangeView(PagedFilteredTableView):
display_message = "You need to be logged in to view this page"
table_class = ProjectTable
queryset = Project.objects.all()
template_name = 'matter_allocation/change_project.html'
paginate_by = ITEMS_PER_PAGE
formhelper_class = ProjectFilterFormHelper
filter_class = ProjectFilter
def get_context_data(self, **kwargs):
context = super(AllocationChangeView,
self).get_context_data(**kwargs)
table = context['table']
table.exclude = ('project_status','department')
table.extra_columns =(('Change',CheckBoxColumn(checked=False)),)
context['table'] = table
return context
注: http://django-tables2.readthedocs.io/en/latest/pages/reference.html – Jieter