【问题标题】:djangocms-text-ckeditor throwing exception with custom configurationdjangocms-text-ckeditor 使用自定义配置抛出异常
【发布时间】:2015-10-21 02:47:44
【问题描述】:

我正在尝试提供自定义 djangocms-text-ckeditor 配置,以减少 Django-CMS 3.0.13 项目中富文本插件中可用选项的数量。

根据documentation,我正在扩展模型和CMSPlugin:

# models.py

class WysiwygText(AbstractText):

    def __unicode__(self):
        return truncatechars(truncatewords_html(self.content, 10), 20)

    @property
    def name(self):
        return self

# cms_plugins.py

WYSIWYG_CKEDITOR_CONFIGURATION = {
    'language': 'en',
    'toolbar_CMS': [
        ['cmsplugins', '-', 'Bold', 'Italic', 'BulletedList'],
        ['Undo', 'Redo'],
    ],
    'skin': 'moono',
    'toolbarCanCollapse': False,
}

class WysiwygPlugin(TextPlugin):
    admin_preview = False
    ckeditor_configuration = WYSIWYG_CKEDITOR_CONFIGURATION
    model = WysiwygText
    name = _('WYSIWYG Text')

当我尝试编辑这个插件时,我得到:

TypeError 在 /en/admin/cms/page/edit-plugin/58/ getattr(): 属性名必须是字符串

完整的例外在这里:https://gist.github.com/alsoicode/cae2c4cc0824c34ed208

我做错了什么?

【问题讨论】:

  • 感谢 downvoter,提醒我,当您在 Stack Overflow 上累得要死时,没有地方可以犯愚蠢的错误。

标签: django django-cms djangocms-text-ckeditor


【解决方案1】:

ckeditor_confugration 应该是一个字符串。在你的情况下'WYSIWYG_CKEDITOR_CONFIGURATION'。此外,该配置必须在您的 Django 设置中,而不是插件中。

【讨论】:

  • 如果您将配置放入一个在插件模块之前自动加载的模块中,它也真的会有所帮助,例如 settings.py :)
猜你喜欢
  • 2014-01-31
  • 2014-07-13
  • 2013-07-05
  • 2011-10-06
  • 2011-05-30
  • 1970-01-01
  • 1970-01-01
  • 2020-08-03
相关资源
最近更新 更多