djangocms-text-ckeditor 使用自定义配置抛出异常
djangocms-text-ckeditor throwing exception with custom configuration
我正在尝试提供自定义 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 at /en/admin/cms/page/edit-plugin/58/
getattr(): attribute name must be string
完整的异常在这里:https://gist.github.com/alsoicode/cae2c4cc0824c34ed208
我做错了什么?
ckeditor_confugration
应该是一个字符串。在你的情况下 'WYSIWYG_CKEDITOR_CONFIGURATION'
。此外,该配置必须在您的 Django 设置中,而不是插件中。
我正在尝试提供自定义 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 at /en/admin/cms/page/edit-plugin/58/ getattr(): attribute name must be string
完整的异常在这里:https://gist.github.com/alsoicode/cae2c4cc0824c34ed208
我做错了什么?
ckeditor_confugration
应该是一个字符串。在你的情况下 'WYSIWYG_CKEDITOR_CONFIGURATION'
。此外,该配置必须在您的 Django 设置中,而不是插件中。