【问题标题】:django-tables2 'module' object has no attribute 'LinkColumn'django-tables2 'module' 对象没有属性 'LinkColumn'
【发布时间】:2014-04-21 02:08:31
【问题描述】:

我在使用 django-tables2 和自定义模板渲染时遇到了这个问题。 当我添加另一列时出现问题,该列未在模型中指定,并弹出错误AttributeError: 'module' object has no attribute 'LinkColumn'。 当仅使用模型列时,表格和自定义渲染工作。

【问题讨论】:

  • 你能添加一些代码吗?您在哪里以及如何添加LinkColumn
  • 感谢 Alex 的快速回答,但我想通了。我错误地从 django-tables2 导入了表,而不是像应该做的那样创建别名。我使用了这个:from django-tables2 import tables 当它应该是:import django-tables2 as tables 感谢 dyve 和 bradleyayers 在这个线程中神秘地回答了这个问题github.com/bradleyayers/django-tables2/issues/79

标签: django python-2.7 django-tables2


【解决方案1】:

您可以使用tables.columns.LinkColumn 代替tables.LinkColumn。 我这样解决了我的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-14
    • 2014-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 1970-01-01
    • 2017-12-02
    相关资源
    最近更新 更多