Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering a callable attribute value in a LinkColumn #858

Open
alexey-nikolov-basemark-com opened this issue Aug 3, 2022 · 1 comment
Open

Comments

@alexey-nikolov-basemark-com

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:

value = v() if callable(v) else v

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?

@jieter
Copy link
Owner

jieter commented Dec 26, 2022

Yes, I agree this is inconstant and should be improved.

Pull requests adding the improvement with documentation an tests welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants