简体   繁体   English

django-tinymce插件没有加载django 1.8

[英]django-tinymce plugins not loading django 1.8

I'm trying to implement django-tinymce in my project. 我正在尝试在我的项目中实现django-tinymce。 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. 我喜欢在撰写博客文章时使用一些富文本功能,因此我的目标是将HTMLField应用于管理员的正文。

The settings that I am currently using are really simple - this is what I have in settings.py: 我目前使用的设置非常简单 - 这就是我在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: 这是在models.py中:

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

and I call the .js in the heads like so: 我会像这样在头脑中调用.js:

<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 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 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. 我发现这个插件和按钮列表真的很有帮助 - 我之前没有得到的是你只加载到你的django应用程序中的插件,但为了使用它们,你需要调用它们的按钮。 Really straightforward once you get it, but there you go. 一旦你得到它真的很直白,但你去了。

Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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