How to deactivate WYMeditor in Django-CMS to use only plain HTML?

django, django-cms, wymeditor

Solution

I found my solution. Basically, I override the plugin for the TextPlugin. I added this to my `cms_plugins.py`:

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from cms.plugins.text.models import Text
from cms.plugins.text.cms_plugins import TextPlugin as TextPluginCMS

class TextPlugin(CMSPluginBase):
    model = Text
    name = _("Text Plugin")
    render_template = "text.html"

plugin_pool.unregister_plugin(TextPluginCMS)
plugin_pool.register_plugin(TextPlugin)

class EditorTextPlugin(TextPluginCMS):
    name = _("Editor Text Plugin")

plugin_pool.register_plugin(EditorTextPlugin)

Notice:

I unregister the original `TextPlugin` (`plugin_pool.unregister_plugin(TextPluginCMS)`) and register a new `TextPlugin` that simply inherits from `CMSPluginBase`. That will get rid off the annoying Editor.

I register another `EditorTextPlugin` that inherits from the original `TextEditor` (`from cms.plugins.text.cms_plugins import TextPlugin as TextPluginCMS`). I just rewrite the name of the plugin.

With this, all the existent text plugins won't use any editor by default. Moreover, I am still able to use the Editor with the `EditorTextPlugin`.

Finally, I can control which plugins use the editor with the `CMS_PLACEHOLDER_CONF` in the settings.py:

CMS_PLACEHOLDER_CONF = {
    'my_placeholder': {
        'plugins': { 'TextPlugin', 'EditorTextPlugin'}
    },
}

No boring migrations needed. When I want to use the Editor, I just add a new `EditorTextPlugin` and copy and paste the content.

EDITS

As @Melissa pointed out in the comments. You do need to add the template `text.html` with `{{instance.body|safe}}` into the the templates directory.

As of django-cms 3.x, the Text model is imported like: `from djangocms_text_ckeditor.models import Text`. Thanks @northben

Problem

I would like to introduce plain html without the need of any Editor (wymeditor or tinymce). I know Django-CMS comes with Wymeditor but my problem is that copy & paste text is annoying. Even if there is no format, Wymeditor likes to add style to the paragraphs when I simply copy (without any format). Sometimes, I don't even need another paragraph inside my placeholders (and it messes with my style). Is there a way to get rid-off the editor? Moreover, is there a way to get rid-off the editor for a particular placeholder? Sometimes I do need it. NOTE: I know that I can create my own plugin with a `field.textfield` (and it doesn't use the editor), but I would like to use the same plugin because if I change the plugin I would have to move all the texts manually in the database (production and development).

Original source