Ensure all table columns are capable of rendering plain text #4627

Closed
opened 2025-12-29 18:38:27 +01:00 by adam · 2 comments
Owner

Originally created by @jeremystretch on GitHub (Mar 4, 2021).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

All custom table columns should define a value() method which returns a plain text string suitable for CSV-formatted output. This output should not contain any HTML.

Similarly, we'll need to look into options for supporting plaintext rendering on template columns. By default, calling value() on a TemplateColumn calls strip_tags() on the output of its render() method, though I'm wondering if we might come up with something more elegant.

Justification

This work is necessary to support #4999, which seeks to generate CSV exports using the table class.

Originally created by @jeremystretch on GitHub (Mar 4, 2021). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes All custom table columns should define a `value()` method which returns a plain text string suitable for CSV-formatted output. This output should not contain any HTML. Similarly, we'll need to look into options for supporting plaintext rendering on template columns. By default, calling `value()` on a TemplateColumn calls `strip_tags()` on the output of its `render()` method, though I'm wondering if we might come up with something more elegant. ### Justification This work is necessary to support #4999, which seeks to generate CSV exports using the table class.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 18:38:27 +01:00
adam closed this issue 2025-12-29 18:38:28 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 5, 2021):

Submitted a PR to django-tables2 to call strip() to remove leading and trailing whitespace when rendering the plaintext value ofa TemplateColumn. If accepted, this will obviate much of the necessary template cleanup.

@jeremystretch commented on GitHub (Mar 5, 2021): Submitted a [PR to django-tables2](https://github.com/jieter/django-tables2/pull/794) to call `strip()` to remove leading and trailing whitespace when rendering the plaintext value ofa TemplateColumn. If accepted, this will obviate much of the necessary template cleanup.
Author
Owner

@jeremystretch commented on GitHub (Mar 8, 2021):

Marking as blocked for now; waiting to see if the aforementioned PR will be accepted upstream.

@jeremystretch commented on GitHub (Mar 8, 2021): Marking as blocked for now; waiting to see if the aforementioned PR will be accepted upstream.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4627