How to enable plugin in django-tinymce?

I started using tinymce in my django project. I need to include some plugins that come with django-tinymce (like a template). So, in my .py settings, I added the following configuration:

TINYMCE_DEFAULT_CONFIG = {
    'theme': 'advanced', 'relative_urls': False,
    'plugins': 'template',
    'toolbar': 'template'
}
MAX_UPLOAD_SIZE = 512000

I think they can enable the template plugin, but it seems not. How to enable plugin in django-tinymce? I did not find anything.

Thanks for your suggestions!

UPDATE:

I think I misunderstood how it is configured. I created config.js with some configuration:

tinyMCE.init({
    theme: 'advanced',
    plugins: 'template',
    height: '350px',
    width: '1000px'
});

Then I linked it to MyModelAdmin.Media. (I am downloading the editor from django-admin.)

class MyModelAdmin(ModelAdmin):
    class Media:
        from django.conf import settings
        js = (
            settings.STATIC_URL + 'tiny_mce/config.js',
        )

config.js looks right, but I don't see any difference.

+4
1

mce_attrs TinyMCE tinymce.

from django import forms
from django.contrib.flatpages.models import FlatPage
from tinymce.widgets import TinyMCE


class FlatPageForm(forms.ModelForm):

    content = forms.CharField(widget=TinyMCE(mce_attrs={
        'theme': 'advanced',
        'plugins': 'template',
        'height': '350px',
        'width': '1000px'
    }))

    class Meta:
        model = FlatPage
+2

Source: https://habr.com/ru/post/1535036/


All Articles