jieter/django-tables2

Rendering a callable attribute value in a LinkColumn

オープン

#858 opened on 2022/08/03

 (1 件のコメント) (0 件のリアクション) (0 人の担当者)Python (443 件のフォーク)batch import
Help wanted

Repository metrics

Stars
 (2,012 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

Working example:

class OverviewTable(django_tables2.Table):
    label = django_tables2.LinkColumn(
        'details',
        args=[django_tables2.utils.A('pk')],
        attrs = {'td': {'id': lambda value: value}},
    )

Expected to work but not working example:

class OverviewTable(django_tables2.Table):
    label = django_tables2.LinkColumn(
        'details',
        args=[django_tables2.utils.A('pk')],
        attrs = {'a': {'id': lambda value: value}},
    )

Raises TypeError: <lambda>() missing 1 required positional argument: 'value' at this point: https://github.com/jieter/django-tables2/blob/7a30b0a1d8ab78f010df91af8fd5d31e411b8122/django_tables2/utils.py#L468

Surely, the documentation doesn't directly suggest that it works, but it seems reasonable to assume. Also the documentation doesn't give a clue that a callable is even supported here. Seems like an unfinished effort to make it work?

コントリビューターガイド