extra_colums를 사용하려고 시도했지만 오류가 발생하지 않지만 테이블이 표시되지 않습니다. here의 설명서를 사용했습니다. 테이블에 체크 박스가있는 열을 추가하려고합니다. 이미 테이블을 미리 정의하고 일부 필드를 제외 할 수 있지만 문서를 사용하면 새 열을 추가하는 방법을 알 수 없습니다. 내가 뭔가를 놓치고 있어야합니다django_tables2.tables에서 extra_columns 사용.
구현은 아래에서 볼 수 있습니다. 어떤 도움을 주시면 감사하겠습니다. 보기
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