3

I have a table defined like this using django-tables2:

class MyTable(tables.Table):
    action = tables.Column()

    class Meta:
        model = User
        fields = ['name', 'email']

    def render_action(self, record):
        return 'Foo'

But the render_action method is ignored and a -- is printed for every row instead. What am I missing?

Federico B.
  • 941
  • 8
  • 19

1 Answers1

11

I finally solved it adding empty_values=() to the action column attributes.

Federico B.
  • 941
  • 8
  • 19
  • This behaviour is documented here: https://django-tables2.readthedocs.io/en/latest/pages/api-reference.html?highlight=empty_values#django_tables2.columns.Column.render – Jim P. Jun 14 '21 at 19:31
  • 1
    I don't understand why the docs require this override, because my rows had data being rendered but it was ignored until I added `empty_values=()`. Does anyone have a better explanation? – Addison Klinke Apr 23 '22 at 04:01