def render_table(request,
                 table=None,
                 links=None,
                 context=None,
                 template_name='tri_table/list.html',
                 blank_on_empty=False,
                 paginate_by=40,
                 page=None,
                 context_processors=None,
                 paginator=None,
                 show_hits=False,
                 hit_label='Items',
                 **kwargs):
    if not context:
        context = {}

    kwargs = collect_namespaces(kwargs)

    if table is None or isinstance(table, dict):
        table_kwargs = table if isinstance(table, dict) else kwargs.pop('table', {})
        if 'model' not in table_kwargs:
            table_kwargs['model'] = table_kwargs['data'].model
        table = Table.from_model(**table_kwargs)

    table.prepare(request)

    context['bulk_form'] = table.bulk_form
    context['query_form'] = table.query_form
    context['tri_query_error'] = table.query_error

    if table.bulk_form and request.method == 'POST':
        pks = [key[len('pk_'):] for key in request.POST if key.startswith('pk_')]

        if table.bulk_form.is_valid():
            table.Meta.model.objects.all() \
                .filter(pk__in=pks) \
                .filter(**table.Meta.bulk_filter) \
                .exclude(**table.Meta.bulk_exclude) \
                .update(**{field.name: field.value for field in table.bulk_form.fields if field.value is not None and field.value is not ''})

        return HttpResponseRedirect(request.META['HTTP_REFERER'])

    context = table_context(request,
                            table=table,
                            links=links,
                            paginate_by=paginate_by,
                            page=page,
                            extra_context=context,
                            context_processors=context_processors,
                            paginator=paginator,
                            show_hits=show_hits,
                            hit_label=hit_label)

    if not table.data and blank_on_empty:  # pragma: no cover
        return ''

    if table.query_form and not table.query_form.is_valid():
        table.data = None
        context['invalid_form_message'] = mark_safe('<i class="fa fa-meh-o fa-5x" aria-hidden="true"></i>')

    return get_template(template_name).render(context)
Render a table. This automatically handles pagination, sorting, filtering and bulk operations.
dataset/ETHPy150Open TriOptima/tri.table/lib/tri/table/__init__.py/render_table