Hi,
Django noob here, am stuck and can not find an example to help me past my error.
Could now like to add a checkbox to each row, so the user can select multiple rows and then select a button at the bottom of the table for further processing of those rows.
But am getting following error Exception Type: Key Error Exception Value: 'selection'
tables.py
import django_tables2 as tables
from .models import Person
class PersonTable(tables.Table):
#selection = tables.CheckBoxColumn(accessor="pk", attrs = { "th__input": {"onclick": "toggle(this)"}}, orderable=False)
selection = tables.CheckBoxColumn(accessor='pk', orderable=False)
attrs = {'class': 'paleblue'}
sequence = ('...', 'selection')
views.py
def people(request):
#return render(request, 'application/people.html', {'people': Person.objects.all()})
table = PersonTable(Person.objects.all())
RequestConfig(request).configure(table)
return render(request, 'application/people.html', {'table': table})
Regards,
Thorsten