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

Feature request: Make TemplateColumn more dynamic #928

Open
rixx opened this issue Sep 27, 2023 · 2 comments · May be fixed by #931
Open

Feature request: Make TemplateColumn more dynamic #928

rixx opened this issue Sep 27, 2023 · 2 comments · May be fixed by #931

Comments

@rixx
Copy link

rixx commented Sep 27, 2023

I'm migrating a larger project towards django-tables2, and I'd like to reuse some snippets both for tables and for other locations. TemplateColumn fills that niche very nicely, but it's hard-coded to use record as context object name, which doesn't play well with existing templates.

There are several ways this could be solved with fairly minimal impact:

  • allow to set context_object_name like in other Django places, defaulting to record
  • allow extra_context to be a callable, passing the arguments received by render()
  • move context collection to a get_context_data method allowing for easy subclassing
jieter added a commit that referenced this issue Oct 17, 2023
@jieter
Copy link
Owner

jieter commented Oct 17, 2023

Interesting suggestions!

I did a quick POC for the first two (#931), but they'll have to be documented still. Can you show an example of how you imagine the third suggestion should work?

@rixx
Copy link
Author

rixx commented Oct 17, 2023

Oh cool! I think if 2) is implemented, 3) won't be needed in addition – subclassing is more troublesome anyway than just passing a callable parameter.

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