简体   繁体   English

django-tables2中带有render_ *方法的列不起作用

[英]Column with render_* method in django-tables2 not working

I have a table defined like this using django-tables2 : 我有一个使用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. 但是render_action方法将被忽略,而是为每行打印一个-。 What am I missing? 我想念什么?

最后,我解决了将empty_values=()添加到action列属性的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM