Turns iterables and querysets into HTML tables with pagination, sorting, and template tags, similar in spirit to django.forms for tables.
Overview
Django Tables2 is a Django app that builds HTML tables from data sources. It accepts any iterable and adds convenience for Django querysets, with pagination and column sorting built in. The default UI does not depend on JavaScript.
You can declare tables manually, generate them from Django models, subclass columns for custom behavior, render via a template tag, and use a generic view mixin in class-based views. Documentation covers customization of columns and rows, headers and footers, pagination, filtering, export, localization, and pinned rows.
Installation adds django_tables2 to INSTALLED_APPS; you define Table classes, pass them from views, and render with the provided template tag in templates. It is tested against supported Django and Python versions and published on PyPI with docs on Read the Docs.
The library focuses on server-rendered list pages where tabular data needs sortable columns and pages without hand-writing table markup each time.
Key features
- HTML tables from iterables or querysets
- Pagination and column sorting
- No JavaScript required in default UI
- Auto tables from Django models
- Custom columns via subclassing
- Template tag for rendering
- Generic view mixin
- Filtering and export support
Use cases
- Sortable list pages in Django
- Paginated admin-style data tables
- Model-backed report tables
- Server-rendered tabular dashboards