简体   繁体   中英

django-tinymce plugins not loading django 1.8

I'm trying to implement django-tinymce in my project. I'd love to use some rich text capability when writing my blog posts, so I'm aiming at applying the HTMLField to the body in the admin.

The settings that I am currently using are really simple - this is what I have in settings.py:

TINYMCE_DEFAULT_CONFIG = {
'theme': "advanced",
'plugins': "wordcount,preview,emotions,", //only wordcount seems to have any effect
'height': "400px",
'width': "700px",

}

this is in the models.py:

from tinymce import models as tinymce_models
...
body = tinymce_models.HTMLField()

and I call the .js in the heads like so:

<script type="text/javascript" src="{% static "tiny_mce/tiny_mce.js" %}"></script>

My issue - no matter what I do in the settings, I get the same result:

Here is what I got

I would appreciate any pointers to what I might be doing wrong.

Thanks a bunch!

Deyan

So, after banging my head for a few days, this is what I finally achieved.

settings.py

# tinymce
TINYMCE_DEFAULT_CONFIG = {
    'theme': "advanced",
    'plugins': "wordcount,preview,emotions,preview,spellchecker,",
    'height': "400px",
    'width': "700px",
    'theme_advanced_buttons3' : "fontselect,fontsizeselect,emotions,preview,",
    }

models.py

from tinymce.models import HTMLField
...

    body = HTMLField()

result:

在此输入图像描述

As you can see, smilies are smiling beautifully, I've got control over font family and size, it's looking really ugly, but it works and this is the price you pay for hacking stuff I suppose. But it works!

I found this list of plugins and buttons really helpful - what I wasn't getting before was that the plugins you only load into your django app, but in order to use them, you need to call their buttons. Really straightforward once you get it, but there you go.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM