djangodjango-cmsdjangocms-text-ckeditor

djangocms-text-ckeditor throwing exception with custom configuration


I'm trying to supply a custom djangocms-text-ckeditor configuration to reduce the number of available options in a rich-text plugin in a Django-CMS 3.0.13 project.

Per the documentation, I am extending the Model and CMSPlugin as such:

# 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')

When I attempt to edit this plugin, I get:

TypeError at /en/admin/cms/page/edit-plugin/58/ getattr(): attribute name must be string

The full exception is here: https://gist.github.com/alsoicode/cae2c4cc0824c34ed208

What am I doing wrong?


Solution

  • ckeditor_confugration should be a string. in your case 'WYSIWYG_CKEDITOR_CONFIGURATION'. Also that configuration must be in your Django settings, not the plugin.