pax_global_header 0000666 0000000 0000000 00000000064 14533553457 0014530 g ustar 00root root 0000000 0000000 52 comment=8885e322f79f376ccb7aff32a7b4c7c27e3bade3
django-tables2-2.7.0/ 0000775 0000000 0000000 00000000000 14533553457 0014332 5 ustar 00root root 0000000 0000000 django-tables2-2.7.0/.coveragerc 0000664 0000000 0000000 00000000137 14533553457 0016454 0 ustar 00root root 0000000 0000000 [run]
source =
django_tables2
tests
branch = true
[html]
directory = reports/htmlcov
django-tables2-2.7.0/.github/ 0000775 0000000 0000000 00000000000 14533553457 0015672 5 ustar 00root root 0000000 0000000 django-tables2-2.7.0/.github/dependabot.yml 0000664 0000000 0000000 00000000166 14533553457 0020525 0 ustar 00root root 0000000 0000000 version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
django-tables2-2.7.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14533553457 0017727 5 ustar 00root root 0000000 0000000 django-tables2-2.7.0/.github/workflows/ci.yml 0000664 0000000 0000000 00000004521 14533553457 0021047 0 ustar 00root root 0000000 0000000 name: CI
on: [push, pull_request]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: actions/checkout@v4
- run: pip install pre-commit
- run: pre-commit run --show-diff-on-failure --all-files
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
django-version: [3.2, 4.1, 4.2, 5.0]
exclude:
# Django 3.2
- python-version: "3.10"
django-version: 3.2
- python-version: 3.11
django-version: 3.2
- python-version: 3.12
django-version: 3.2
# Django 4.1
- python-version: 3.12
django-version: 4.1
# Django 4.2
- python-version: 3.12
django-version: 4.2
# Django 5.0
- python-version: 3.8
django-version: 5.0
- python-version: 3.9
django-version: 5.0
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4
- uses: actions/cache@v3.3.2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- run: python -m pip install Django==${{ matrix.django-version }}
if: matrix.django-version != 'master'
- run: python -m pip install https://github.com/django/django/archive/master.tar.gz
if: matrix.django-version == 'master'
- run: |
python -m pip install coverage
python -m pip install -r requirements/common.pip
- run: coverage run --source=django_tables2 manage.py test
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4.7.1
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: |
docs/requirements.txt
common/requirements.txt
- name: Install and build
run: |
cd docs
python -m pip install -r requirements.txt
make html
django-tables2-2.7.0/.gitignore 0000664 0000000 0000000 00000000431 14533553457 0016320 0 ustar 00root root 0000000 0000000 *.pyc
/.env
/reports
/*.sublime-*
/*.komodoproject
/*.tmproj
/*.egg-info/
/*.egg
/.tox
/.coverage
/MANIFEST
/dist/
/build/
/docs/_build/
/docs/pages/CHANGELOG.md
/example/database.sqlite
/example/.env
/report.pylint
.cache/
.python-version
.idea
*.sw[po]
pip-wheel-metadata
.vscode django-tables2-2.7.0/.pre-commit-config.yaml 0000664 0000000 0000000 00000000652 14533553457 0020616 0 ustar 00root root 0000000 0000000 repos:
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
django-tables2-2.7.0/.readthedocs.yaml 0000664 0000000 0000000 00000000625 14533553457 0017564 0 ustar 00root root 0000000 0000000 # Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
python:
install:
- requirements: docs/requirements.txt
django-tables2-2.7.0/.readthedocs.yml 0000664 0000000 0000000 00000000763 14533553457 0017426 0 ustar 00root root 0000000 0000000 # .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt django-tables2-2.7.0/CHANGELOG.md 0000664 0000000 0000000 00000125002 14533553457 0016143 0 ustar 00root root 0000000 0000000 # Change log
## 2.7.0 (2023-12-05)
- Update docs dependencies; fix docs search; add readthedocs.yaml ([#935](https://github.com/jieter/django-tables2/pull/935))
- Add example on how to use `Accessor` to documentation in `custom-data.rst` ([#917](https://github.com/jieter/django-tables2/pull/917)) by [@ruddra](https://github.com/ruddra)
- Use pre-commit in ci, add isort, flake8, pyupgrade ([#932](https://github.com/jieter/django-tables2/pull/932))
- Add support for Django 5.0 and Python 3.12 ([#930](https://github.com/jieter/django-tables2/pull/930))
- Add missing `{% load l10n %}` in templates ([#919](https://github.com/jieter/django-tables2/pull/919)) by [@tvanekeris](https://github.com/tvanekeris)
## 2.6.0 (2023-06-27)
- Fix bootstrap5-responsive template to extend bootstrap5 ([#909](https://github.com/jieter/django-tables2/pull/909)) by [@mschoettle](https://github.com/mschoettle)
- Add support for django 4.2
- Drop python 3.7 and django 4.0 support ([#920](https://github.com/jieter/django-tables2/pull/920))
## 2.5.3 (2023-03-05)
- Assign request to table before anything else in `RequestConfig.configure()` ([#888](https://github.com/jieter/django-tables2/pull/888)) fixes: [#865](https://github.com/jieter/django-tables2/issues/865)
- Add type hints to get_context_data ([#895](https://github.com/jieter/django-tables2/pull/895)) by [@mschoettle](https://github.com/mschoettle)
- Document hidden table attributes setting ([#897](https://github.com/jieter/django-tables2/pull/897)) by [@mschoettle](https://github.com/mschoettle)
- Fix building of the docs ([#900](https://github.com/jieter/django-tables2/pull/900)) by [@danielroseman](https://github.com/danielroseman)
- Add template bootstrap5-responsive.html ([#896](https://github.com/jieter/django-tables2/pull/896)) by [@mschoettle](https://github.com/mschoettle)
## 2.5.2 (2023-02-07)
- Assign `request` to table before anything else in `RequestConfig.configure()` ([#888](https://github.com/jieter/django-tables2/pull/888)) fixes: [#865](https://github.com/jieter/django-tables2/issues/865)
## 2.5.1 (2023-01-07)
- `TableMixinBase`: implement `get_paginate_by` ([#811](https://github.com/jieter/django-tables2/pull/811)) by [@Alirezaja1384](https://github.com/Alirezaja1384)
## 2.5.0 (2022-12-27)
- Dropped support for python 3.6, added support for python 3.11
- Add django_tables2/bootstrap4-responsive.html ([#874](https://github.com/jieter/django-tables2/pull/874)) by [@botlabsDev](https://github.com/botlabsDev)
- Pass record/value to `LinkColumn`'s attrs callables too ([#852](https://github.com/jieter/django-tables2/pull/852)) by [@wsldankers](https://github.com/wsldankers)
- Add template `bootstrap5.html` to support bootstrap 5 ([#880](https://github.com/jieter/django-tables2/pull/880), fixes [#796](https://github.com/jieter/django-tables2/issues/796)
## 2.4.1 (2021-10-04)
- Add Persian (Farsi) locale ([#806](https://github.com/jieter/django-tables2/pull/806)) by [@Alirezaja1384](https://github.com/jieter/django-tables2/commits?author=Alirezaja1384)
- Improved error message if openpyxl is not installed ([#816](https://github.com/jieter/django-tables2/pull/816))
- Use correct mime type for xlsx (fixes: [#810](https://github.com/jieter/django-tables2/issues/810))
- Add support for django 4.0, drop support for python 3.5 ([#822](https://github.com/jieter/django-tables2/issues/822))
## 2.4.0 (2021-05-15)
- Add support for django 3.2 and python 3.9, drop support for django 3.0
- Add Django 3.0 and 3.1 trove classifiers [#803](https://github.com/jieter/django-tables2/pull/803) by [@Asday](https://github.com/Asday)
- Strip leading and trailing whitespace from TemplateColumn.value() [#794](https://github.com/jieter/django-tables2/pull/794) by [@jeremystretch](https://github.com/jeremystretch)
- Providing link for django-bootstrap3 [#793](https://github.com/jieter/django-tables2/pull/793) by [@TareqMonwer](https://github.com/TareqMonwer)
- Fix for crash on windows while deleting temp file [#788](https://github.com/jieter/django-tables2/pull/788)
## 2.3.4 (2021-01-10)
- Removed deprecation warnings with django==3.1 regarding `JSONField` [#785](https://github.com/jieter/django-tables2/pull/785)
## 2.3.3 (2020-10-29)
- Use `table.default` for empty `ManyToMany` relations ([#773](https://github.com/jieter/django-tables2/pull/773)) fixes: [#769](https://github.com/jieter/django-tables2/issues/769)
- Pass record/value to `CheckboxColumn`'s `attrs` callables too ([#774](https://github.com/jieter/django-tables2/pull/774)), fixes: [#762](https://github.com/jieter/django-tables2/issues/762)
## 2.3.2 (2020-10-10)
- Fix popping the extra_context of TemplateColumn [#767](https://github.com/jieter/django-tables2/pull/767) by [@bernhardmiller](https://github.com/bernhardmiller)
- Fix typo for the translation of the word 'next' in greek [#759]](https://github.com/jieter/django-tables2/pull/759) by [@orfeasa](https://github.com/orfeasa)
- Add `format_html` import to prevent `NameError` [#752](https://github.com/jieter/django-tables2/pull/752) by [@MBfromOK](https://github.com/MBfromOK)
- Fixed Russian translation [#768](https://github.com/jieter/django-tables2/pull/768) by [@Real-Gecko](https://github.com/Real-Gecko)
## 2.3.1 (2020-04-02)
- Fixed the `LazyPaginator` in a simpler more predictable way: an attempt to show a non-existent page, shows the first page. [#743](https://github.com/jieter/django-tables2/pull/743)
## 2.3.0 (2020-03-31)
- Add ability to pass `tablib.Dataset` `kwargs` via `TableExport` and `ExportMixin` [#720](https://github.com/jieter/django-tables2/pull/720) by [@powderflask](https://github.com/powderflask)
- Drop django==2.1 support, add optional tablib requirements [#738](https://github.com/jieter/django-tables2/pull/738)
- Short-circuit `Accessor.resolve()` if the context contains the exact accessor [#722](https://github.com/jieter/django-tables2/pull/722), fixes [#717](https://github.com/jieter/django-tables2/issues/717)
- Fixed yaml export [#732](https://github.com/jieter/django-tables2/pull/732) by [@sg3-141-592](https://githug.com/sg3-141-592)
- Made Table docstring visible in docs [#742](https://github.com/jieter/django-tables2/pull/742)
- Removed the TableBase construct in favor of using the `metaclass` keyword argument, as all supported python versions support it. [#742](https://github.com/jieter/django-tables2/pull/742)
- `LazyPaginator` with non-existent page number should not result in a crash [#741](https://github.com/jieter/django-tables2/pull/741)
## 2.2.1 (2019-11-20)
- Fix backwards-compatibility with legacy separators in order_by clauses ([#715](https://github.com/jieter/django-tables2/pull/715) by [@federicobond](https://github.com/federicobond))
## 2.2.0 (2019-11-18)
- Use `__` as accessor-separator, add `linkify` Meta option [#702](https://github.com/jieter/django-tables2/pull/702)).
This will currently emit a warning but falls back to using `.` as separator. The next major version will raise a `ValueError` if used with `.` as separator.
- Add request attribute to table instance ([#705](https://github.com/jieter/django-tables2/pull/705) by [@rubickcz](https://github.com/rubickcz)).
- Append ellipsis for `LazyPaginator` if not on last page ([#707](https://github.com/jieter/django-tables2/pull/707) by [@tuky](https://github.com/tuky))
## 2.1.1 (2019-09-23)
- Made `ManyToManyColumn` use `table.default` instead of a local value [#680](https://github.com/jieter/django-tables2/pull/680) by [@srtab](https://github.com/srtab)
- Removed invalid scope attribute in `
` element of `bootstrap4.html`. [#691](https://github.com/jieter/django-tables2/pull/691) by [@vlt](https://github.com/vlt)
- Fixed an issue with incorrectly disabled pagination where `SingleTableMixin` was not used together with `ListView` [#678](https://github.com/jieter/django-tables2/pull/678) by [@nieuwenhuys](https://github.com/nieuwenhuys)
## 2.1.0 (2019-07-22)
- Dropped support for python 2.7 (and django 1.11).
- Removed `django_tables2.utils.ucfirst`, use `django.utils.text.capfirst` instead.
- Removed `class="thead-default"` from bootstrap4 template ([#671](https://github.com/jieter/django-tables2/issues/671))
- Included columns with `visible=False` in export ([#677](https://github.com/jieter/django-tables2/pull/677))
- Fixed pagination when the number of pages is equal to page range plus one ([#655](https://github.com/jieter/django-tables2/pull/655))
## 2.0.6 (2019-03-26)
- Add optional 'table' kwarg to `row_attrs` callables
## 2.0.5 (2019-02-21)
- Fixes issue with wrong time format for TimeColumn [#650](https://github.com/jieter/django-tables2/pull/650) by [@IgorCode](https://github.com/IgorCode)
## 2.0.4 (2019-01-21)
- The `ValueError` raised if the QuerySet passed to a table instance did not match the value declared in `Meta.model` is now turned into a warning (fixes [#643](https://github.com/jieter/django-tables2/issues/643))
- Make sure the templates do not raise errors when `thead`/`tfoot` attributes are not defined [#624](https://github.com/jieter/django-tables2/pull/624) by [@intiocean](https://github.com/intiocean)
## 2.0.3 (2018-11-11)
- Improvements in packaging and publishing helper scripts reducing the package size considerably [#630](https://github.com/jieter/django-tables2/pull/630) by [@wtayyeb](https://github.com/wtayyeb) (fixes [#629](https://github.com/jieter/django-tables2/issues/629))
- Documentation improvements fixing [#625](https://github.com/jieter/django-tables2/issues/625), [#631](https://github.com/jieter/django-tables2/issues/631)
## 2.0.2 (2018-10-22)
- Make sure the value of the class attribute in `
` tags) by default.
Previous behavior can be restored by using this method on your custom table:
```python
class MyTable(tables.Table):
# columns
def get_column_class_names(self, classes_set, bound_column):
classes_set = super(MyTable, self).get_column_class_names(classes_set, bound_column)
classes_set.add(bound_column.name)
return classes_set
```
- `verbose_name`s derived from model fields are not passed through `title()` anymore, only the first character is converted to upper case. This follows [Django's convention for verbose field names](https://docs.djangoproject.com/en/2.0/topics/db/models/#verbose-field-names): "The convention is not to capitalize the first letter of the verbose_name. Django will automatically capitalize the first letter where it needs to." (Fixes [#475](https://github.com/jieter/django-tables2/issues/475) and [#491](https://github.com/jieter/django-tables2/issues/491))
## 1.21.2 (2018-03-26)
- Moved table instantiation from `get_context_data` to `get_tables` [#554](https://github.com/jieter/django-tables2/pull/554) by [@sdolemelipone](https://github.com/sdolemelipone)
- Pass request as kwarg to `template.render()`, rather than as part of context. (fixes [#552](https://github.com/jieter/django-tables2/issues/552))
## 1.21.1 (2018-03-12)
- Do not perform extra `COUNT()` queries for non-paginated tables. Fixes [#551](https://github.com/jieter/django-tables2/issues/551)
## 1.21.0 (2018-03-12)
- Add new method `paginated_rows` to `Table` to replace fallback to non-paginated rows in templates.
- Prevent mutation of the template context `{% render_table %}` is called from (fixes [#547](https://github.com/jieter/django-tables2/issues/547))
**Possible breaking change**: the context variables of the template `{% render_table %}` is called from is no longer available in the table's template. The `table` variable has an attribute `context`, which is the context of the calling template. Use `{{ table.context.variable }}` instead of `{{ variable }}`.
## 1.20.0 (2018-03-08)
- Define and use `get_table_data` in `MultiTableMixin` [#538](https://github.com/jieter/django-tables2/pull/538) by [@vCra](https://github.com/vCra) (fixes [#528](https://github.com/jieter/django-tables2/issues/528))
- Added `{% export_url %}` template tag.
- Allow passing a `TableData`-derived class to the data argument of the `Table` constructor, instead of a QuerySet or list of dicts.
## 1.19.0 (2018-02-02)
- `BoundColumn.attrs` does not evaluate `current_value` as `bool` [#536](https://github.com/jieter/django-tables2/pull/536) by [@pachewise](https://github.com/pachewise) (fixes [#534](https://github.com/jieter/django-tables2/issues/534))
- Allow more flexible access to cell values (especially useful for django templates) (fixes [#485](https://github.com/jieter/django-tables2/issues/485))
## 1.18.0 (2018-01-27)
- Follow relations when detecting column type for fields in `Table.Meta.fields` (fixes [#498](https://github.com/jieter/django-tables2/issues/498))
- Renamed `Table.Meta.template` to `template_name` (with deprecation warning for the former) [#542](https://github.com/jieter/django-tables2/pull/524) (fixes [#520](https://github.com/jieter/django-tables2/issues/520))
- Added Czech translation [#533](https://github.com/jieter/django-tables2/pull/533) by [@OndraRehounek](https://github.com/OndraRehounek)
- Added `table_factory` [#532](https://github.com/jieter/django-tables2/pull/532) by [@ZuluPro](https://github.com/ZuluPro)
## 1.17.1 (2017-12-14)
- Fix typo in setup.py for `extras_require`.
## 1.17.0 (2017-12-14)
- Dropped support for Django 1.8, 1.9 and 1.10.
- Add `extra_context` argument to `TemplateColumn` [#509](https://github.com/jieter/django-tables2/pull/509) by [@ad-m](https://github.com/ad-m)
- Remove unnecessary cast of record to `str` [#514](https://github.com/jieter/django-tables2/pull/514), fixes [#511](https://github.com/jieter/django-tables2/issues/511)
- Use `django.test.TestCase` for all tests, and remove dependency on pytest and reorganized some tests [#515](https://github.com/jieter/django-tables2/pull/515)
- Remove traces of django-haystack tests from the tests, there were no actual tests.
## 1.16.0 (2017-11-27)
This is the last version supporting Django 1.8, 1.9 and 1.10. Django 1.8 is only supported until April 2018, so consider upgrading to Django 1.11!
- Added `tf` dictionary to `Column.attrs` with default values for the footer, so footers now have `class` attribute by default [#501](https://github.com/jieter/django-tables2/pull/501) by [@mpasternak](https://github.com/mpasternak)
## 1.15.0 (2017-11-23)
- Added `as=varname` keyword argument to the `{% querystring %}` template tag,
fixes [#481](https://github.com/jieter/django-tables2/issues/481)
- Updated the tutorial to reflect current state of Django a bit better.
- Used `OrderedDict` rather than `dict` as the parent for `utils.AttributeDict` to make the rendered html more consistent across python versions.
- Allow reading column `attrs` from a column's attribute, allowing easier reuse of custom column attributes (fixes [#241](https://github.com/jieter/django-tables2/issues/241))
- `value` and `record` are optionally passed to the column attrs callables for data rows. [#503](https://github.com/jieter/django-tables2/pull/503), fixes [#500](https://github.com/jieter/django-tables2/issues/500)
## 1.14.2 (2017-10-30)
- Added a `row_counter` variable to the template context in `TemplateColumn` (fixes [#448](https://github.com/jieter/django-tables2/issues/488))
## 1.14.1 (2017-10-30)
- Do not fail if `orderable=False` is passed to `ManyToManyColumn()`
## 1.14.0 (2017-10-30)
- Added `separator` argument to `ManyToManyColumn`.
- Allow `mark_safe()`'d strings from `ManyToManyColumn.tranform()`
- Disabled ordering on `ManyToManyColumns` by default.
## 1.13.0 (2017-10-17)
- Made positional `data` argument to the table `__init__()` a keyword argument to make inheritance easier. Will raise a `TypeError` if omitted.
## 1.12.0 (2017-10-10)
- Allow export file name customization [#484](https://github.com/bradleyayers/django-tables2/pull/484) by [@federicobond](https://github.com/federicobond)
- Fixed a bug where template columns were not rendered for pinned rows ([#483](https://github.com/bradleyayers/django-tables2/pull/483) by [@khirstinova](https://github.com/khirstinova), fixes [#482](https://github.com/bradleyayers/django-tables2/issues/482))
## 1.11.0 (2017-09-15)
- Added Hungarian translation [#471](https://github.com/bradleyayers/django-tables2/pull/471) by [@hmikihth](https://github.com/hmikihth).
- Added TemplateColumn.value() and enhanced export docs (fixes [#470](https://github.com/bradleyayers/django-tables2/issues/470))
- Fixed display of pinned rows if table has no data. [#477](https://github.com/bradleyayers/django-tables2/pull/477) by [@khirstinova](https://github.com/khirstinova)
## 1.10.0 (2017-06-30)
- Added `ManyToManyColumn` automatically added for `ManyToManyField`s.
## 1.9.1 (2017-06-29)
- Allow customizing the value used in `Table.as_values()` (when using a `render_` method) using a `value_` method. (fixes [#458](https://github.com/bradleyayers/django-tables2/issues/458))
- Allow excluding columns from the `Table.as_values()` output. (fixes [#459](https://github.com/bradleyayers/django-tables2/issues/459))
- Fixed unicode handling for column headers in `Table.as_values()`
## 1.9.0 (2017-06-22)
- Allow computable attrs for `
` to have no HTML attributes.
## v0.9.5
- Updated example project to add `colspan` on footer cell so table border renders correctly in Webkit.
- Fix regression that caused 'sortable' class on
.
- `Table.__init__` no longer *always* calls `.order_by()` on QuerySets, fixes #55.
This does introduce a slight backwards incompatibility. `Table.order_by` now has the possibility of returning `None`, previously it would *always* return an `OrderByTuple`.
- `DeclarativeColumnsMetaclass.__new__` now uses `super()``
- Testing now requires pylint and Attest >=0.5.3
## v0.9.4
- Fix regression that caused column verbose_name values that were marked as
safe to be escaped. Now any verbose_name values that are instances of
SafeData are used unmodified.
## v0.9.3
- Fix regression in `SingleTableMixin`.
- Remove stray `print` statement.
## v0.9.2
- `SingleTableView` now uses `RequestConfig`. This fixes issues with
`order_by_field`, `page_field`, and `per_page_field` not being honored.
- Add `Table.Meta.per_page` and change `Table.paginate` to use it as default.
- Add `title` template filter. It differs from Django's built-in `title` filter
because it operates on an individual word basis and leaves words containing
capitals untouched. **Warning**: use `{% load ... from ... %}` to avoid
inadvertently replacing Django's built-in `title` template filter.
- `BoundColumn.verbose_name` no longer does `capfirst`, capitalizing is now the
responsibility of `Column.header`.
- `BoundColumn.__unicode__` now uses `BoundColumn.header` rather than
`BoundColumn.verbose_name`.
## v0.9.1
- Fix version in `setup.py`
## v0.9.0
- Add support for column attributes (see Attrs)
- Add `BoundRows.items()` to yield `(bound_column, cell)` pairs
- Tried to make docs more concise. Much stronger promotion of using
`RequestConfig` and `{% querystring %}`
## v0.8.4
- Removed random 'print' statements.
- Tweaked `paleblue` theme css to be more flexible:
- removed `whitespace: no-wrap`
- header background image to support more than 2 rows of text
## v0.8.3
- Fixed stupid import mistake. Tests did not pick it up due to them ignoring `ImportError`.
## v0.8.2
- `SingleTableView` now inherits from `ListView` which enables automatic
`foo_list.html` template name resolution (thanks dramon for reporting)
- `render_table` template tag no suppresses exceptions when `DEBUG=True`
## v0.8.1
- Fixed bug in render_table when giving it a template (issue #41)
## v0.8.0
- Added translation support in the default template via `{% trans %}`
- Removed `basic_table.html`, `Table.as_html()` now renders `table.html` but
will clobber the query string of the current request. Use the `render_table`
template tag instead
- `render_table` now supports an optional second argument -- the template to
use when rendering the table
- `Table` now supports declaring which template to use when rendering to HTML
- Django >=1.3 is now required
- Added support for using django-haystack's `SearchQuerySet` as a data source
- The default template `table.html` now includes block tags to make it easy to
extend to change small pieces
- Fixed table template parsing problems being hidden due to a subsequent
exception being raised
- `Http404` exceptions are no longer raised during a call to `Table.paginate()`,
instead it now occurs when `Table.page` is accessed
- Fixed bug where a table could not be rendered more than once if it was paginated.
- Accessing `Table.page` now returns a new page every time, rather than reusing
a single object
## v0.7.8
- Tables now support using both `sequence` and `exclude` (issue #32).
- `Sequence` class moved to `django_tables2/utils.py`.
- Table instances now support modification to the `exclude` property.
- Removed `BoundColumns._spawn_columns`.
- `Table.data`, `Table.rows`, and `Table.columns` are now attributes
rather than properties.
django-tables2-2.7.0/CONTRIBUTING.md 0000664 0000000 0000000 00000003363 14533553457 0016570 0 ustar 00root root 0000000 0000000 # Contributing to django-tables2
You are welcome to contribute to the development of `django-tables2` in various ways:
- Discover and [report bugs](https://github.com/jieter/django-tables2/issues/new).
Make sure to include a minimal example to show your problem.
- Propose features, add tests or fix bugs by [opening a Pull Request](https://github.com/jieter/django-tables2/compare)
- Fix documentation or translations
When contributing features or making bug fixes, please add unit tests to verify the expected behaviour.
This helps
## Coding style
We use [black](https://black.readthedocs.io/en/stable/) to format the sources, with a 100 char line length.
Before committing, run `black .`, or use `pre-commit`:
```
pip install pre-commit
pre-commit install
```
## Running the tests
With `tox` installed, you can run the test suite in all supported environments by typing `tox`.
During development, you might not want to wait for the tests to run in all environments,
in that case, use the `-e` argument to specify a specific environment.
For example `tox -e py36-2.0` will run the tests in python 3.6 with Django 2.0.
You can also run the tests only in your current environment, using
`PYTHONPATH=. ./manage.py test` (which is even quicker).
## Code coverage
To generate a html coverage report:
```
coverage run --source=django_tables2 manage.py test
coverage html
```
## Building the documentation
If you want to build the docs from within a virtualenv, and Sphinx is installed globally, use:
```
cd docs/
make html SPHINXBUILD="python $(which sphinx-build)"
```
Publishing a release
--------------------
1. Bump the version in `django-tables2/__init__.py`.
2. Update `CHANGELOG.md`.
3. Create a tag `./maintenance.py tag`.
4. Run `./maintenance.py publish`
django-tables2-2.7.0/LICENSE 0000664 0000000 0000000 00000003167 14533553457 0015346 0 ustar 00root root 0000000 0000000 All changes made to django-tables2 since forking from django-tables
are Copyright (c) 2011, Bradley Ayers
All rights reserved.
Redistribution is permitted under the same terms as the original
django-tables license. The original django-tables license is included
below.
Copyright (c) 2008, Michael Elsdörfer
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
django-tables2-2.7.0/MANIFEST.in 0000664 0000000 0000000 00000000507 14533553457 0016072 0 ustar 00root root 0000000 0000000 include README.md
include CHANGELOG.md
include LICENSE
exclude docs/pages/CHANGELOG.md
recursive-exclude docs/_build *
recursive-include django_tables2/templates *
recursive-include django_tables2/static *
recursive-include django_tables2/locale *
recursive-include example/app/fixtures *
recursive-include example/templates *
django-tables2-2.7.0/README.md 0000664 0000000 0000000 00000004745 14533553457 0015623 0 ustar 00root root 0000000 0000000 # django-tables2 - An app for creating HTML tables
[](https://pypi.python.org/pypi/django-tables2)
[](https://github.com/ambv/black)
django-tables2 simplifies the task of turning sets of data into HTML tables. It
has native support for pagination and sorting. It does for HTML tables what
`django.forms` does for HTML forms. e.g.
- Available on pypi as [django-tables2](https://pypi.python.org/pypi/django-tables2)
- Tested against currently supported versions of Django
[and supported python 3 versions Django supports](https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django).
- [Documentation on readthedocs.org](https://django-tables2.readthedocs.io/en/latest/)
- [Bug tracker](http://github.com/jieter/django-tables2/issues)
Features:
- Any iterable can be a data-source, but special support for Django `QuerySets` is included.
- The builtin UI does not rely on JavaScript.
- Support for automatic table generation based on a Django model.
- Supports custom column functionality via subclassing.
- Pagination.
- Column based table sorting.
- Template tag to enable trivial rendering to HTML.
- Generic view mixin.



## Example
Start by adding `django_tables2` to your `INSTALLED_APPS` setting like this:
```python
INSTALLED_APPS = (
...,
"django_tables2",
)
```
Creating a table for a model `Simple` is as simple as:
```python
import django_tables2 as tables
class SimpleTable(tables.Table):
class Meta:
model = Simple
```
This would then be used in a view:
```python
class TableView(tables.SingleTableView):
table_class = SimpleTable
queryset = Simple.objects.all()
template_name = "simple_list.html"
```
And finally in the template:
```
{% load django_tables2 %}
{% render_table table %}
```
This example shows one of the simplest cases, but django-tables2 can do a lot more!
Check out the [documentation](https://django-tables2.readthedocs.io/en/latest/) for more details.
django-tables2-2.7.0/django_tables2/ 0000775 0000000 0000000 00000000000 14533553457 0017210 5 ustar 00root root 0000000 0000000 django-tables2-2.7.0/django_tables2/__init__.py 0000664 0000000 0000000 00000001662 14533553457 0021326 0 ustar 00root root 0000000 0000000 from .columns import (
BooleanColumn,
CheckBoxColumn,
Column,
DateColumn,
DateTimeColumn,
EmailColumn,
FileColumn,
JSONColumn,
LinkColumn,
ManyToManyColumn,
RelatedLinkColumn,
TemplateColumn,
TimeColumn,
URLColumn,
)
from .config import RequestConfig
from .paginators import LazyPaginator
from .tables import Table, table_factory
from .utils import A
from .views import MultiTableMixin, SingleTableMixin, SingleTableView
__version__ = "2.7.0"
__all__ = (
"Table",
"table_factory",
"BooleanColumn",
"Column",
"CheckBoxColumn",
"DateColumn",
"DateTimeColumn",
"EmailColumn",
"FileColumn",
"JSONColumn",
"LinkColumn",
"ManyToManyColumn",
"RelatedLinkColumn",
"TemplateColumn",
"TimeColumn",
"URLColumn",
"RequestConfig",
"A",
"SingleTableMixin",
"SingleTableView",
"MultiTableMixin",
"LazyPaginator",
)
django-tables2-2.7.0/django_tables2/columns/ 0000775 0000000 0000000 00000000000 14533553457 0020670 5 ustar 00root root 0000000 0000000 django-tables2-2.7.0/django_tables2/columns/__init__.py 0000664 0000000 0000000 00000001567 14533553457 0023012 0 ustar 00root root 0000000 0000000 from .base import BoundColumn, BoundColumns, Column, library
from .booleancolumn import BooleanColumn
from .checkboxcolumn import CheckBoxColumn
from .datecolumn import DateColumn
from .datetimecolumn import DateTimeColumn
from .emailcolumn import EmailColumn
from .filecolumn import FileColumn
from .jsoncolumn import JSONColumn
from .linkcolumn import LinkColumn, RelatedLinkColumn
from .manytomanycolumn import ManyToManyColumn
from .templatecolumn import TemplateColumn
from .timecolumn import TimeColumn
from .urlcolumn import URLColumn
__all__ = (
"library",
"BoundColumn",
"BoundColumns",
"Column",
"BooleanColumn",
"CheckBoxColumn",
"DateColumn",
"DateTimeColumn",
"EmailColumn",
"FileColumn",
"JSONColumn",
"LinkColumn",
"ManyToManyColumn",
"RelatedLinkColumn",
"TemplateColumn",
"URLColumn",
"TimeColumn",
)
django-tables2-2.7.0/django_tables2/columns/base.py 0000664 0000000 0000000 00000077567 14533553457 0022202 0 ustar 00root root 0000000 0000000 from collections import OrderedDict
from itertools import islice
from django.core.exceptions import ImproperlyConfigured
from django.urls import reverse
from django.utils.html import format_html
from django.utils.safestring import SafeData
from django.utils.text import capfirst
from ..utils import (
Accessor,
AttributeDict,
OrderBy,
OrderByTuple,
call_with_appropriate,
computed_values,
)
class Library:
"""A collection of columns."""
def __init__(self):
self.columns = []
def register(self, column):
if not hasattr(column, "from_field"):
raise ImproperlyConfigured(f"{column.__class__.__name__} is not a subclass of Column")
self.columns.append(column)
return column
def column_for_field(self, field, **kwargs):
"""
Return a column object suitable for model field.
Returns:
`.Column` object or `None`
"""
if field is None:
return self.columns[0](**kwargs)
# Iterate in reverse order as columns are registered in order
# of least to most specialised (i.e. Column is registered
# first). This also allows user-registered columns to be
# favoured.
for candidate in reversed(self.columns):
if hasattr(field, "get_related_field"):
verbose_name = field.get_related_field().verbose_name
else:
verbose_name = getattr(field, "verbose_name", field.name)
kwargs["verbose_name"] = capfirst(verbose_name)
column = candidate.from_field(field, **kwargs)
if column is None:
continue
return column
# The library is a mechanism for announcing what columns are available. Its
# current use is to allow the table metaclass to ask columns if they're a
# suitable match for a model field, and if so to return an approach instance.
library = Library()
class LinkTransform:
"""Object used to generate attributes for the ``-tag to wrap the cell content in."""
viewname = None
accessor = None
attrs = None
def __init__(self, url=None, accessor=None, attrs=None, reverse_args=None):
"""
arguments:
url (callable): If supplied, the result of this callable will be used as ``href`` attribute.
accessor (Accessor): if supplied, the accessor will be used to decide on which object
``get_absolute_url()`` is called.
attrs (dict): Customize attributes for the ```` tag.
Values of the dict can be either static text or a
callable. The callable can optionally declare any subset
of the following keyword arguments: value, record, column,
bound_column, bound_row, table. These arguments will then
be passed automatically.
reverse_args (dict, tuple): Arguments to ``django.urls.reverse()``. If dict, the arguments
are assumed to be keyword arguments to ``reverse()``, if tuple, a ``(viewname, args)``
or ``(viewname, kwargs)``
"""
self.url = url
self.attrs = attrs
self.accessor = accessor
if isinstance(reverse_args, (list, tuple)):
viewname, args = reverse_args
reverse_args = {"viewname": viewname}
reverse_args["kwargs" if isinstance(args, dict) else "args"] = args
self.reverse_args = reverse_args or {}
def compose_url(self, **kwargs):
if self.url and callable(self.url):
return call_with_appropriate(self.url, kwargs)
bound_column = kwargs.get("bound_column", None)
record = kwargs["record"]
if self.reverse_args.get("viewname", None) is not None:
return self.call_reverse(record=record)
if bound_column is None and self.accessor is None:
accessor = Accessor("")
else:
accessor = Accessor(self.accessor if self.accessor is not None else bound_column.name)
context = accessor.resolve(record)
if not hasattr(context, "get_absolute_url"):
if hasattr(record, "get_absolute_url"):
context = record
else:
raise TypeError(
f"for linkify=True, '{context}' must have a method get_absolute_url"
)
return context.get_absolute_url()
def call_reverse(self, record):
"""
Prepares the arguments to reverse() for this record and calls reverse()
"""
def resolve_if_accessor(val):
return val.resolve(record) if isinstance(val, Accessor) else val
params = self.reverse_args.copy()
params["viewname"] = resolve_if_accessor(params["viewname"])
if params.get("urlconf", None):
params["urlconf"] = resolve_if_accessor(params["urlconf"])
if params.get("args", None):
params["args"] = [resolve_if_accessor(a) for a in params["args"]]
if params.get("kwargs", None):
params["kwargs"] = {
key: resolve_if_accessor(val) for key, val in params["kwargs"].items()
}
if params.get("current_app", None):
params["current_app"] = resolve_if_accessor(params["current_app"])
return reverse(**params)
def get_attrs(self, **kwargs):
attrs = AttributeDict(computed_values(self.attrs or {}, kwargs=kwargs))
attrs["href"] = self.compose_url(**kwargs)
return attrs
def __call__(self, content, **kwargs):
attrs = self.get_attrs(**kwargs)
if attrs["href"] is None:
return content
return format_html("{}", attrs.as_html(), content)
@library.register
class Column:
"""
Represents a single column of a table.
`.Column` objects control the way a column (including the cells that fall
within it) are rendered.
Arguments:
attrs (dict): HTML attributes for elements that make up the column.
This API is extended by subclasses to allow arbitrary HTML
attributes to be added to the output.
By default `.Column` supports:
- ``th`` -- ``table/thead/tr/th`` elements
- ``td`` -- ``table/tbody/tr/td`` elements
- ``cell`` -- fallback if ``th`` or ``td`` is not defined
- ``a`` -- To control the attributes for the ``a`` tag if the cell
is wrapped in a link.
accessor (str or `~.Accessor`): An accessor that describes how to
extract values for this column from the :term:`table data`.
default (str or callable): The default value for the column. This can be
a value or a callable object [1]_. If an object in the data provides
`None` for a column, the default will be used instead.
The default value may affect ordering, depending on the type of data
the table is using. The only case where ordering is not affected is
when a `.QuerySet` is used as the table data (since sorting is
performed by the database).
empty_values (iterable): list of values considered as a missing value,
for which the column will render the default value. Defaults to
`(None, '')`
exclude_from_export (bool): If `True`, this column will not be added to
the data iterator returned from as_values().
footer (str, callable): Defines the footer of this column. If a callable
is passed, it can take optional keyword arguments `column`,
`bound_column` and `table`.
order_by (str, tuple or `.Accessor`): Allows one or more accessors to be
used for ordering rather than *accessor*.
orderable (bool): If `False`, this column will not be allowed to
influence row ordering/sorting.
verbose_name (str): A human readable version of the column name.
visible (bool): If `True`, this column will be rendered.
Columns with `visible=False` will not be rendered, but will be included
in ``.Table.as_values()`` and thus also in :ref:`export`.
localize: If the cells in this column will be localized by the
`localize` filter:
- If `True`, force localization
- If `False`, values are not localized
- If `None` (default), localization depends on the ``USE_L10N`` setting.
linkify (bool, str, callable, dict, tuple): Controls if cell content will be wrapped in an
``a`` tag. The different ways to define the ``href`` attribute:
- If `True`, the ``record.get_absolute_url()`` or the related model's
`get_absolute_url()` is used.
- If a callable is passed, the returned value is used, if it's not ``None``.
The callable can optionally accept any argument valid for :ref:`table.render_foo`-methods,
for example `record` or `value`.
- If a `dict` is passed, it's passed on to ``~django.urls.reverse``.
- If a `tuple` is passed, it must be either a (viewname, args) or (viewname, kwargs)
tuple, which is also passed to ``~django.urls.reverse``.
Examples, assuming this model::
class Blog(models.Model):
title = models.CharField(max_length=100)
body = model.TextField()
user = model.ForeignKey(get_user_model(), on_delete=models.CASCADE)
Using the ``linkify`` argument to control the linkification. These columns will all display
the value returned from `str(record.user)`::
# If the column is named 'user', the column will use record.user.get_absolute_url()
user = tables.Column(linkify=True)
# We can also do that explicitly:
user = tables.Column(linkify=lambda record: record.user.get_absolute_url())
# or, if no get_absolute_url is defined, or a custom link is required, we have a couple
# of ways to define what is passed to reverse()
user = tables.Column(linkify={"viewname": "user_detail", "args": [tables.A("user__pk")]})
user = tables.Column(linkify=("user_detail", [tables.A("user__pk")])) # (viewname, args)
user = tables.Column(linkify=("user_detail", {"pk": tables.A("user__pk")})) # (viewname, kwargs)
initial_sort_descending (bool): If `True`, a column will sort in descending order
on "first click" after table has been rendered. If `False`, column will follow
default behavior, and sort ascending on "first click". Defaults to `False`.
.. [1] The provided callable object must not expect to receive any arguments.
"""
# Tracks each time a Column instance is created. Used to retain order.
creation_counter = 0
empty_values = (None, "")
# by default, contents are not wrapped in an -tag.
link = None
# Explicit is set to True if the column is defined as an attribute of a
# class, used to give explicit columns precedence.
_explicit = False
def __init__(
self,
verbose_name=None,
accessor=None,
default=None,
visible=True,
orderable=None,
attrs=None,
order_by=None,
empty_values=None,
localize=None,
footer=None,
exclude_from_export=False,
linkify=False,
initial_sort_descending=False,
):
if not (accessor is None or isinstance(accessor, str) or callable(accessor)):
raise TypeError(f"accessor must be a string or callable, not {type(accessor).__name__}")
if callable(accessor) and default is not None:
raise TypeError("accessor must be string when default is used, not callable")
self.accessor = Accessor(accessor) if accessor else None
self._default = default
self.verbose_name = verbose_name
self.visible = visible
self.orderable = orderable
self.attrs = attrs or getattr(self, "attrs", {})
# massage order_by into an OrderByTuple or None
order_by = (order_by,) if isinstance(order_by, str) else order_by
self.order_by = OrderByTuple(order_by) if order_by is not None else None
if empty_values is not None:
self.empty_values = empty_values
self.localize = localize
self._footer = footer
self.exclude_from_export = exclude_from_export
link_kwargs = None
if callable(linkify) or hasattr(self, "get_url"):
link_kwargs = dict(url=linkify if callable(linkify) else self.get_url)
elif isinstance(linkify, (dict, tuple)):
link_kwargs = dict(reverse_args=linkify)
elif linkify is True:
link_kwargs = dict(accessor=self.accessor)
if link_kwargs is not None:
self.link = LinkTransform(attrs=self.attrs.get("a", {}), **link_kwargs)
self.initial_sort_descending = initial_sort_descending
self.creation_counter = Column.creation_counter
Column.creation_counter += 1
@property
def default(self):
return self._default() if callable(self._default) else self._default
@property
def header(self):
"""
The value used for the column heading (e.g. inside the ``
`` tag).
By default this returns `~.Column.verbose_name`.
:returns: `unicode` or `None`
.. note::
This property typically is not accessed directly when a table is
rendered. Instead, `.BoundColumn.header` is accessed which in turn
accesses this property. This allows the header to fallback to the
column name (it is only available on a `.BoundColumn` object hence
accessing that first) when this property doesn't return something
useful.
"""
return self.verbose_name
def footer(self, bound_column, table):
"""Return the content of the footer, if specified."""
footer_kwargs = {"column": self, "bound_column": bound_column, "table": table}
if self._footer is not None:
if callable(self._footer):
return call_with_appropriate(self._footer, footer_kwargs)
else:
return self._footer
if hasattr(self, "render_footer"):
return call_with_appropriate(self.render_footer, footer_kwargs)
return ""
def render(self, value):
"""
Return the content for a specific cell.
This method can be overridden by :ref:`table.render_FOO` methods on the
table or by subclassing `.Column`.
If the value for this cell is in `.empty_values`, this method is
skipped and an appropriate default value is rendered instead.
Subclasses should set `.empty_values` to ``()`` if they want to handle
all values in `.render`.
"""
return value
def value(self, **kwargs):
"""
Return the content for a specific cell for exports.
Similar to `.render` but without any html content.
This can be used to get the data in the formatted as it is presented but in a
form that could be added to a csv file.
The default implementation just calls the `render` function but any
subclasses where `render` returns html content should override this
method.
See `LinkColumn` for an example.
"""
value = call_with_appropriate(self.render, kwargs)
return value
def order(self, queryset, is_descending):
"""
Order the QuerySet of the table.
This method can be overridden by :ref:`table.order_FOO` methods on the
table or by subclassing `.Column`; but only overrides if second element
in return tuple is True.
returns:
Tuple (QuerySet, boolean)
"""
return (queryset, False)
@classmethod
def from_field(cls, field, **kwargs):
"""
Return a specialized column for the model field or `None`.
Arguments:
field (Model Field instance): the field that needs a suitable column
Returns:
`.Column` object or `None`
If the column is not specialized for the given model field, it should
return `None`. This gives other columns the opportunity to do better.
If the column is specialized, it should return an instance of itself
that is configured appropriately for the field.
"""
# Since this method is inherited by every subclass, only provide a
# column if this class was asked directly.
if cls is Column:
return cls(**kwargs)
class BoundColumn:
"""
A run-time version of `.Column`.
The difference between `.BoundColumn` and `.Column`,
is that `.BoundColumn` objects include the relationship between a `.Column` and a `.Table`.
In practice, this means that a `.BoundColumn` knows the *"variable name"* given to the `.Column`
when it was declared on the `.Table`.
arguments:
table (`~.Table`): The table in which this column exists
column (`~.Column`): The type of column
name (str): The variable name of the column used when defining the
`.Table`. In this example the name is ``age``::
class SimpleTable(tables.Table):
age = tables.Column()
"""
def __init__(self, table, column, name):
self._table = table
self.column = column
self.name = name
self.link = column.link
self.current_value = None
def __str__(self):
return str(self.header)
@property
def accessor(self):
"""Returns the string used to access data for this column out of the data source."""
return self.column.accessor or Accessor(self.name)
@property
def attrs(self):
"""
Proxy to `.Column.attrs` but injects some values of our own.
A ``th``, ``td`` and ``tf`` are guaranteed to be defined (irrespective
of what is actually defined in the column attrs. This makes writing
templates easier. ``tf`` is not actually a HTML tag, but this key name
will be used for attributes for column's footer, if the column has one.
"""
# prepare kwargs for computed_values()
kwargs = {"table": self._table, "bound_column": self}
# BoundRow.items() sets current_record and current_value when iterating over
# the records in a table.
if (
getattr(self, "current_record", None) is not None
and getattr(self, "current_value", None) is not None
):
kwargs.update({"record": self.current_record, "value": self.current_value})
# Start with table's attrs; Only 'th' and 'td' attributes will be used
attrs = dict(self._table.attrs)
# Update attrs to prefer column's attrs rather than table's
attrs.update(dict(self.column.attrs))
# we take the value for 'cell' as the basis for both the th and td attrs
cell_attrs = attrs.get("cell", {})
# override with attrs defined specifically for th and td respectively.
attrs["th"] = computed_values(attrs.get("th", cell_attrs), kwargs=kwargs)
attrs["td"] = computed_values(attrs.get("td", cell_attrs), kwargs=kwargs)
attrs["tf"] = computed_values(attrs.get("tf", cell_attrs), kwargs=kwargs)
# wrap in AttributeDict
attrs["th"] = AttributeDict(attrs["th"])
attrs["td"] = AttributeDict(attrs["td"])
attrs["tf"] = AttributeDict(attrs["tf"])
# Override/add classes
attrs["th"]["class"] = self.get_th_class(attrs["th"])
attrs["td"]["class"] = self.get_td_class(attrs["td"])
attrs["tf"]["class"] = self.get_td_class(attrs["tf"])
return attrs
def _get_cell_class(self, attrs):
"""
Return a set of the classes from the class key in ``attrs``.
"""
classes = attrs.get("class", None)
classes = set() if classes is None else set(classes.split(" "))
return self._table.get_column_class_names(classes, self)
def get_td_class(self, td_attrs):
"""
Returns the HTML class attribute for a data cell in this column
"""
classes = sorted(self._get_cell_class(td_attrs))
return None if len(classes) == 0 else " ".join(classes)
def get_th_class(self, th_attrs):
"""
Returns the HTML class attribute for a header cell in this column
"""
classes = self._get_cell_class(th_attrs)
# add classes for ordering
ordering_class = th_attrs.get("_ordering", {})
if self.orderable:
classes.add(ordering_class.get("orderable", "orderable"))
if self.is_ordered:
classes.add(
ordering_class.get("descending", "desc")
if self.order_by_alias.is_descending
else ordering_class.get("ascending", "asc")
)
return None if len(classes) == 0 else " ".join(sorted(classes))
@property
def default(self):
"""Returns the default value for this column."""
value = self.column.default
if value is None:
value = self._table.default
return value
@property
def header(self):
"""The contents of the header cell for this column."""
# favour Column.header
column_header = self.column.header
if column_header:
return column_header
# fall back to automatic best guess
return self.verbose_name
@property
def footer(self):
"""The contents of the footer cell for this column."""
return call_with_appropriate(
self.column.footer, {"bound_column": self, "table": self._table}
)
def has_footer(self):
return self.column._footer is not None or hasattr(self.column, "render_footer")
@property
def order_by(self):
"""
Return an `.OrderByTuple` of appropriately prefixed data source keys used to sort this column.
See `.order_by_alias` for details.
"""
if self.column.order_by is not None:
order_by = self.column.order_by
else:
# default to using column accessor as data source sort key
order_by = OrderByTuple((self.accessor,))
return order_by.opposite if self.order_by_alias.is_descending else order_by
@property
def order_by_alias(self):
"""
Return an `OrderBy` describing the current state of ordering for this column.
The following attempts to explain the difference between `order_by`
and `.order_by_alias`.
`.order_by_alias` returns and `.OrderBy` instance that's based on
the *name* of the column, rather than the keys used to order the table
data. Understanding the difference is essential.
Having an alias *and* a keys version is necessary because an N-tuple
(of data source keys) can be used by the column to order the data, and
it is ambiguous when mapping from N-tuple to column (since multiple
columns could use the same N-tuple).
The solution is to use order by *aliases* (which are really just
prefixed column names) that describe the ordering *state* of the
column, rather than the specific keys in the data source should be
ordered.
e.g.::
>>> class SimpleTable(tables.Table):
... name = tables.Column(order_by=("firstname", "last_name"))
...
>>> table = SimpleTable([], order_by=('-name', ))
>>> table.columns["name"].order_by_alias
"-name"
>>> table.columns["name"].order_by
("-first_name", "-last_name")
The `OrderBy` returned has been patched to include an extra attribute
``next``, which returns a version of the alias that would be
transitioned to if the user toggles sorting on this column, for example::
not sorted -> ascending
ascending -> descending
descending -> ascending
This is useful otherwise in templates you'd need something like::
{% if column.is_ordered %}
{% querystring table.prefixed_order_by_field=column.order_by_alias.opposite %}
{% else %}
{% querystring table.prefixed_order_by_field=column.order_by_alias %}
{% endif %}
"""
order_by = OrderBy((self._table.order_by or {}).get(self.name, self.name))
order_by.next = order_by.opposite if self.is_ordered else order_by
if self.column.initial_sort_descending and not self.is_ordered:
order_by.next = order_by.opposite
return order_by
@property
def is_ordered(self):
return self.name in (self._table.order_by or ())
@property
def orderable(self):
"""Return whether this column supports ordering."""
if self.column.orderable is not None:
return self.column.orderable
return self._table.orderable
@property
def verbose_name(self):
"""
Return the verbose name for this column.
In order of preference, this will return:
1) The column's explicitly defined `verbose_name`
2) The model's `verbose_name` with the first letter capitalized (if applicable)
3) Fall back to the column name, with first letter capitalized.
Any `verbose_name` that was not passed explicitly in the column
definition is returned with the first character capitalized in keeping
with the Django convention of `verbose_name` being defined in lowercase and
uppercased as needed by the application.
If the table is using `QuerySet` data, then use the corresponding model
field's `~.db.Field.verbose_name`. If it is traversing a relationship,
then get the last field in the accessor (i.e. stop when the
relationship turns from ORM relationships to object attributes [e.g.
person.upper should stop at person]).
"""
# Favor an explicit defined verbose_name
if self.column.verbose_name is not None:
return self.column.verbose_name
# This is our reasonable fall back, should the next section not result
# in anything useful.
name = self.name.replace("_", " ")
# Try to use a model field's verbose_name
model = self._table.data.model
if model:
field = Accessor(self.accessor).get_field(model)
if field:
if hasattr(field, "field"):
name = field.field.verbose_name
else:
name = getattr(field, "verbose_name", field.name)
# If verbose_name was mark_safe()'d, return intact to keep safety
if isinstance(name, SafeData):
return name
return capfirst(name)
@property
def visible(self):
"""Return whether this column is visible."""
return self.column.visible
@property
def localize(self):
"""Return `True`, `False` or `None` as described in ``Column.localize``"""
return self.column.localize
class BoundColumns:
"""
Container for spawning `.BoundColumn` objects.
This is bound to a table and provides its `.Table.columns` property.
It provides access to those columns in different ways (iterator,
item-based, filtered and unfiltered etc), stuff that would not be possible
with a simple iterator in the table class.
A `BoundColumns` object is a container for holding `BoundColumn` objects.
It provides methods that make accessing columns easier than if they were
stored in a `list` or `dict`. `Columns` has a similar API to a `dict` (it
actually uses a `~collections.OrderedDict` internally).
At the moment you'll only come across this class when you access a
`.Table.columns` property.
Arguments:
table (`.Table`): the table containing the columns
"""
def __init__(self, table, base_columns):
self._table = table
self.columns = OrderedDict()
for name, column in base_columns.items():
self.columns[name] = bound_column = BoundColumn(table, column, name)
bound_column.render = getattr(table, "render_" + name, column.render)
# How the value is defined: 1. value_ 2. render_ 3. column.value.
bound_column.value = getattr(
table, "value_" + name, getattr(table, "render_" + name, column.value)
)
bound_column.order = getattr(table, "order_" + name, column.order)
def iternames(self):
return (name for name, column in self.iteritems())
def names(self):
return list(self.iternames())
def iterall(self):
"""
Return an iterator that exposes all `.BoundColumn` objects,
regardless of visibility or sortability.
"""
return (column for name, column in self.iteritems())
def all(self):
return list(self.iterall())
def iteritems(self):
"""
Return an iterator of ``(name, column)`` pairs (where ``column`` is a `BoundColumn`).
This method is the mechanism for retrieving columns that takes into
consideration all of the ordering and filtering modifiers that a table
supports (e.g. `~Table.Meta.exclude` and `~Table.Meta.sequence`).
"""
for name in self._table.sequence:
if name not in self._table.exclude:
yield (name, self.columns[name])
def items(self):
return list(self.iteritems())
def iterorderable(self):
"""
Same as `BoundColumns.all` but only returns orderable columns.
This is useful in templates, where iterating over the full
set and checking ``{% if column.ordarable %}`` can be problematic in
conjunction with e.g. ``{{ forloop.last }}`` (the last column might not
be the actual last that is rendered).
"""
return (x for x in self.iterall() if x.orderable)
def itervisible(self):
"""
Same as `.iterorderable` but only returns visible `.BoundColumn` objects.
This is geared towards table rendering.
"""
return (x for x in self.iterall() if x.visible)
def hide(self, name):
"""
Hide a column.
Arguments:
name(str): name of the column
"""
self.columns[name].column.visible = False
def show(self, name):
"""
Show a column otherwise hidden.
Arguments:
name(str): name of the column
"""
self.columns[name].column.visible = True
def __iter__(self):
"""Convenience API, alias of `.itervisible`."""
return self.itervisible()
def __contains__(self, item):
"""
Check if a column is contained within a `BoundColumns` object.
*item* can either be a `~.BoundColumn` object, or the name of a column.
"""
if isinstance(item, str):
return item in self.iternames()
else:
# let's assume we were given a column
return item in self.iterall()
def __len__(self):
"""Return how many `~.BoundColumn` objects are contained (and visible)."""
return len(list(self.itervisible()))
def __getitem__(self, index):
"""
Retrieve a specific `~.BoundColumn` object.
*index* can either be 0-indexed or the name of a column
.. code-block:: python
columns['speed'] # returns a bound column with name 'speed'
columns[0] # returns the first column
"""
if isinstance(index, int):
try:
return next(islice(self.iterall(), index, index + 1))
except StopIteration:
raise IndexError
elif isinstance(index, str):
for column in self.iterall():
if column.name == index:
return column
raise KeyError(
f"Column with name '{index}' does not exist; choices are: {self.names()}"
)
else:
raise TypeError(f"Column indices must be integers or str, not {type(index).__name__}")
django-tables2-2.7.0/django_tables2/columns/booleancolumn.py 0000664 0000000 0000000 00000004661 14533553457 0024106 0 ustar 00root root 0000000 0000000 from django.db import models
from django.utils.html import escape, format_html
from ..utils import AttributeDict
from .base import Column, library
@library.register
class BooleanColumn(Column):
"""
A column suitable for rendering boolean data.
Arguments:
null (bool): is `None` different from `False`?
yesno (str): comma separated values string or 2-tuple to display for
True/False values.
Rendered values are wrapped in a ```` to allow customization by using
CSS. By default the span is given the class ``true``, ``false``.
In addition to *attrs* keys supported by `~.Column`, the following are
available:
- ``span`` -- adds attributes to the ```` tag
"""
def __init__(self, null=False, yesno="✔,✘", **kwargs):
self.yesno = yesno.split(",") if isinstance(yesno, str) else tuple(yesno)
if not null:
kwargs["empty_values"] = ()
super().__init__(**kwargs)
def _get_bool_value(self, record, value, bound_column):
# If record is a model, we need to check if it has choices defined.
if hasattr(record, "_meta"):
field = bound_column.accessor.get_field(record)
# If that's the case, we need to inverse lookup the value to convert
# to a boolean we can use.
if hasattr(field, "choices") and field.choices is not None and len(field.choices) > 0:
value = next(val for val, name in field.choices if name == value)
value = bool(value)
return value
def render(self, value, record, bound_column):
value = self._get_bool_value(record, value, bound_column)
text = self.yesno[int(not value)]
attrs = {"class": str(value).lower()}
attrs.update(self.attrs.get("span", {}))
return format_html("{}", AttributeDict(attrs).as_html(), escape(text))
def value(self, record, value, bound_column):
"""
Returns the content for a specific cell similarly to `.render` however without any html content.
"""
value = self._get_bool_value(record, value, bound_column)
return str(value)
@classmethod
def from_field(cls, field, **kwargs):
if isinstance(field, models.NullBooleanField):
return cls(null=True, **kwargs)
if isinstance(field, models.BooleanField):
return cls(null=getattr(field, "null", False), **kwargs)
django-tables2-2.7.0/django_tables2/columns/checkboxcolumn.py 0000664 0000000 0000000 00000006203 14533553457 0024247 0 ustar 00root root 0000000 0000000 from django.utils.safestring import mark_safe
from django_tables2.utils import Accessor, AttributeDict, computed_values
from .base import Column, library
@library.register
class CheckBoxColumn(Column):
"""
A subclass of `.Column` that renders as a checkbox form input.
This column allows a user to *select* a set of rows. The selection
information can then be used to apply some operation (e.g. "delete") onto
the set of objects that correspond to the selected rows.
The value that is extracted from the :term:`table data` for this column is
used as the value for the checkbox, i.e. ````
This class implements some sensible defaults:
- HTML input's ``name`` attribute is the :term:`column name` (can override
via *attrs* argument).
- ``orderable`` defaults to `False`.
Arguments:
attrs (dict): In addition to *attrs* keys supported by `~.Column`, the
following are available:
- ``input`` -- ```` elements in both ``
`` and ``
``.
- ``th__input`` -- Replaces ``input`` attrs in header cells.
- ``td__input`` -- Replaces ``input`` attrs in body cells.
checked (`~.Accessor`, bool, callable): Allow rendering the checkbox as
checked. If it resolves to a truthy value, the checkbox will be
rendered as checked.
.. note::
You might expect that you could select multiple checkboxes in the
rendered table and then *do something* with that. This functionality
is not implemented. If you want something to actually happen, you will
need to implement that yourself.
"""
def __init__(self, attrs=None, checked=None, **extra):
self.checked = checked
kwargs = {"orderable": False, "attrs": attrs}
kwargs.update(extra)
super().__init__(**kwargs)
@property
def header(self):
default = {"type": "checkbox"}
general = self.attrs.get("input")
specific = self.attrs.get("th__input")
attrs = AttributeDict(default, **(specific or general or {}))
return mark_safe(f"")
def render(self, value, bound_column, record):
default = {"type": "checkbox", "name": bound_column.name, "value": value}
if self.is_checked(value, record):
default.update({"checked": "checked"})
general = self.attrs.get("input")
specific = self.attrs.get("td__input")
attrs = dict(default, **(specific or general or {}))
attrs = computed_values(attrs, kwargs={"record": record, "value": value})
return mark_safe(f"")
def is_checked(self, value, record):
"""
Determine if the checkbox should be checked
"""
if self.checked is None:
return False
if self.checked is True:
return True
if callable(self.checked):
return bool(self.checked(value, record))
checked = Accessor(self.checked)
if checked in record:
return bool(record[checked])
return False
django-tables2-2.7.0/django_tables2/columns/datecolumn.py 0000664 0000000 0000000 00000001663 14533553457 0023403 0 ustar 00root root 0000000 0000000 from django.db import models
from .base import library
from .templatecolumn import TemplateColumn
@library.register
class DateColumn(TemplateColumn):
"""
A column that renders dates in the local timezone.
Arguments:
format (str): format string in same format as Django's ``date`` template
filter (optional)
short (bool): if `format` is not specified, use Django's
``SHORT_DATE_FORMAT`` setting, otherwise use ``DATE_FORMAT``
"""
def __init__(self, format=None, short=True, *args, **kwargs):
if format is None:
format = "SHORT_DATE_FORMAT" if short else "DATE_FORMAT"
template = '{{ value|date:"%s"|default:default }}' % format
super().__init__(template_code=template, *args, **kwargs)
@classmethod
def from_field(cls, field, **kwargs):
if isinstance(field, models.DateField):
return cls(**kwargs)
django-tables2-2.7.0/django_tables2/columns/datetimecolumn.py 0000664 0000000 0000000 00000001740 14533553457 0024256 0 ustar 00root root 0000000 0000000 from django.db import models
from .base import library
from .templatecolumn import TemplateColumn
@library.register
class DateTimeColumn(TemplateColumn):
"""
A column that renders `datetime` instances in the local timezone.
Arguments:
format (str): format string for datetime (optional).
Note that *format* uses Django's `date` template tag syntax.
short (bool): if `format` is not specified, use Django's
``SHORT_DATETIME_FORMAT``, else ``DATETIME_FORMAT``
"""
def __init__(self, format=None, short=True, *args, **kwargs):
if format is None:
format = "SHORT_DATETIME_FORMAT" if short else "DATETIME_FORMAT"
template = '{{ value|date:"%s"|default:default }}' % format
super().__init__(template_code=template, *args, **kwargs)
@classmethod
def from_field(cls, field, **kwargs):
if isinstance(field, models.DateTimeField):
return cls(**kwargs)
django-tables2-2.7.0/django_tables2/columns/emailcolumn.py 0000664 0000000 0000000 00000002104 14533553457 0023544 0 ustar 00root root 0000000 0000000 from django.db import models
from .base import library
from .linkcolumn import BaseLinkColumn
@library.register
class EmailColumn(BaseLinkColumn):
"""
Render email addresses to `mailto:`-links.
Arguments:
attrs (dict): HTML attributes that are added to the rendered
``...`` tag.
text: Either static text, or a callable. If set, this will be used to
render the text inside link instead of the value.
Example::
# models.py
class Person(models.Model):
name = models.CharField(max_length=200)
email = models.EmailField()
# tables.py
class PeopleTable(tables.Table):
name = tables.Column()
email = tables.EmailColumn()
# result
# [...]email@example.com
"""
def get_url(self, value):
return f"mailto:{value}"
@classmethod
def from_field(cls, field, **kwargs):
if isinstance(field, models.EmailField):
return cls(**kwargs)
django-tables2-2.7.0/django_tables2/columns/filecolumn.py 0000664 0000000 0000000 00000005604 14533553457 0023404 0 ustar 00root root 0000000 0000000 import os
from django.db import models
from django.utils.html import format_html
from ..utils import AttributeDict
from .base import library
from .linkcolumn import BaseLinkColumn
@library.register
class FileColumn(BaseLinkColumn):
"""
Attempts to render `.FieldFile` (or other storage backend `.File`) as a
hyperlink.
When the file is accessible via a URL, the file is rendered as a
hyperlink. The `.basename` is used as the text, wrapped in a span::
receipt.pdf
When unable to determine the URL, a ``span`` is used instead::
receipt.pdf
`.Column.attrs` keys ``a`` and ``span`` can be used to add additional attributes.
Arguments:
verify_exists (bool): attempt to determine if the file exists
If *verify_exists*, the HTML class ``exists`` or ``missing`` is
added to the element to indicate the integrity of the storage.
text (str or callable): Either static text, or a callable. If set, this
will be used to render the text inside the link instead of
the file's ``basename`` (default)
"""
def __init__(self, verify_exists=True, **kwargs):
self.verify_exists = verify_exists
super().__init__(**kwargs)
def get_url(self, value, record):
storage = getattr(value, "storage", None)
if not storage:
return None
return storage.url(value.name)
def text_value(self, record, value):
if self.text is None:
return os.path.basename(value.name)
return super().text_value(record, value)
def render(self, record, value):
attrs = AttributeDict(self.attrs.get("span", {}))
classes = [c for c in attrs.get("class", "").split(" ") if c]
exists = None
storage = getattr(value, "storage", None)
if storage:
# we'll assume value is a `django.db.models.fields.files.FieldFile`
if self.verify_exists:
exists = storage.exists(value.name)
else:
if self.verify_exists and hasattr(value, "name"):
# ignore negatives, perhaps the file has a name but it doesn't
# represent a local path... better to stay neutral than give a
# false negative.
exists = os.path.exists(value.name) or exists
if exists is not None:
classes.append("exists" if exists else "missing")
attrs["title"] = value.name
attrs["class"] = " ".join(classes)
return format_html(
"{text}",
attrs=attrs.as_html(),
text=self.text_value(record, value),
)
@classmethod
def from_field(cls, field, **kwargs):
if isinstance(field, models.FileField):
return cls(**kwargs)
django-tables2-2.7.0/django_tables2/columns/jsoncolumn.py 0000664 0000000 0000000 00000003754 14533553457 0023442 0 ustar 00root root 0000000 0000000 import json
from django.utils.html import format_html
from ..utils import AttributeDict
from .base import library
from .linkcolumn import BaseLinkColumn
try:
try:
from django.contrib.postgres.fields import HStoreField
from django.db.models import JSONField # django==3.1 moved JSONField
except ImportError:
from django.contrib.postgres.fields import HStoreField, JSONField
POSTGRES_AVAILABLE = True
except ImportError:
# psycopg2 is not available, cannot import from django.contrib.postgres.
# JSONColumn might still be useful to add manually.
POSTGRES_AVAILABLE = False
@library.register
class JSONColumn(BaseLinkColumn):
"""
Render the contents of `~django.contrib.postgres.fields.JSONField` or
`~django.contrib.postgres.fields.HStoreField` as an indented string.
.. versionadded :: 1.5.0
.. note::
Automatic rendering of data to this column requires PostgreSQL support
(psycopg2 installed) to import the fields, but this column can also be
used manually without it.
Arguments:
json_dumps_kwargs: kwargs passed to `json.dumps`, defaults to `{'indent': 2}`
attrs (dict): In addition to *attrs* keys supported by `~.Column`, the
following are available:
- ``pre`` -- ``
`` around the rendered JSON string in ``
`` elements.
"""
def __init__(self, json_dumps_kwargs=None, **kwargs):
self.json_dumps_kwargs = (
json_dumps_kwargs if json_dumps_kwargs is not None else {"indent": 2}
)
super().__init__(**kwargs)
def render(self, record, value):
return format_html(
"
{}
",
AttributeDict(self.attrs.get("pre", {})).as_html(),
json.dumps(value, **self.json_dumps_kwargs),
)
@classmethod
def from_field(cls, field, **kwargs):
if POSTGRES_AVAILABLE:
if isinstance(field, (JSONField, HStoreField)):
return cls(**kwargs)
django-tables2-2.7.0/django_tables2/columns/linkcolumn.py 0000664 0000000 0000000 00000013746 14533553457 0023430 0 ustar 00root root 0000000 0000000 from .base import Column, library
class BaseLinkColumn(Column):
"""
The base for other columns that render links.
Arguments:
text (str or callable): If set, this value will be used to render the
text inside link instead of value. The callable gets the record
being rendered as argument.
attrs (dict): In addition to ``attrs`` keys supported by `~.Column`, the
following are available:
- `a` -- ```` in ``
`` elements.
"""
def __init__(self, text=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.text = text
def text_value(self, record, value):
if self.text is None:
return value
return self.text(record) if callable(self.text) else self.text
def value(self, record, value):
"""
Returns the content for a specific cell similarly to `.render` however
without any html content.
"""
return self.text_value(record, value)
def render(self, record, value):
return self.text_value(record, value)
@library.register
class LinkColumn(BaseLinkColumn):
"""
Renders a normal value as an internal hyperlink to another page.
.. note ::
This column should not be used anymore, the `linkify` keyword argument to
regular columns can be used to achieve the same results.
It's common to have the primary value in a row hyperlinked to the page
dedicated to that record.
The first arguments are identical to that of
`~django.urls.reverse` and allows an internal URL to be
described. If this argument is `None`, then `get_absolute_url`.
(see Django references) will be used.
The last argument *attrs* allows custom HTML attributes to be added to the
rendered ```` tag.
Arguments:
viewname (str or None): See `~django.urls.reverse`, or use `None`
to use the model's `get_absolute_url`
urlconf (str): See `~django.urls.reverse`.
args (list): See `~django.urls.reverse`. [2]_
kwargs (dict): See `~django.urls.reverse`. [2]_
current_app (str): See `~django.urls.reverse`.
attrs (dict): HTML attributes that are added to the rendered
``...`` tag.
text (str or callable): Either static text, or a callable. If set, this
will be used to render the text inside link instead of value (default).
The callable gets the record being rendered as argument.
.. [2] In order to create a link to a URL that relies on information in the
current row, `.Accessor` objects can be used in the *args* or *kwargs*
arguments. The accessor will be resolved using the row's record before
`~django.urls.reverse` is called.
Example:
.. code-block:: python
# models.py
class Person(models.Model):
name = models.CharField(max_length=200)
# urls.py
urlpatterns = patterns('',
url("people/([0-9]+)/", views.people_detail, name="people_detail")
)
# tables.py
from django_tables2.utils import A # alias for Accessor
class PeopleTable(tables.Table):
name = tables.LinkColumn("people_detail", args=[A("pk")])
In order to override the text value (i.e. ``text``) consider
the following example:
.. code-block:: python
# tables.py
from django_tables2.utils import A # alias for Accessor
class PeopleTable(tables.Table):
name = tables.LinkColumn("people_detail", text="static text", args=[A("pk")])
age = tables.LinkColumn("people_detail", text=lambda record: record.name, args=[A("pk")])
In the first example, a static text would be rendered (``"static text"``)
In the second example, you can specify a callable which accepts a record object (and thus
can return anything from it)
In addition to *attrs* keys supported by `.Column`, the following are
available:
- `a` -- ```` elements in ``