本文介绍了django-tinymce现代主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将现代主题与django-tinymce配合使用时,我遇到了问题.简单主题和高级主题都可以正确渲染,但是当我切换到现代主题时,没有任何渲染,并且在控制台中/static/tiny_mce/themes/modern/editor_template.js出现404错误

I'm having issues getting the modern theme to work with django-tinymce. Both the simple and the advanced themes render correctly, but when I switch to the modern theme nothing renders and I get a 404 error for /static/tiny_mce/themes/modern/editor_template.js in the console

我正尝试在django管理员中执行所有这些操作.该错误来自/static/tiny_mce/tiny_mce.js,这很有趣,因为我没有在该目录中安装任何东西.我在settings.py中使用/static/js/tinymce作为我的 TINYMCE_JS_ROOT .在简单主题和高级主题之间切换时,一切正常.

I am attempting to do all of this in the django admin. The error is coming from /static/tiny_mce/tiny_mce.js which is interesting because I don't have anything installed in that directory. I'm using /static/js/tinymce as my TINYMCE_JS_ROOT in settings.py. When switching between simple and advanced theme, everything works correctly.

我已经尝试在所需的确切位置复制一个editor_template.js版本,但是我仍然得到404.这就像它消除了/static/tiny_mce的存在并将其替换为某些东西一样,但是我可以无法弄清楚它是如何/从哪里得到的.

I've tried to copy a version of editor_template.js in the exact location it's looking, but I still get the 404. It's like it wipes out /static/tiny_mce if it exists and replaces it with something, but I can't figure out how/where it's getting that from.

我正在从 http://www.tinymce下载安装的TinyMCE 4.1.3.com/download/download.php 和django 1.6.5

I'm using an install of TinyMCE 4.1.3 from http://www.tinymce.com/download/download.php and django 1.6.5

推荐答案

我最近也一直在与TinyMCE挣扎.我正在使用TinyMCE v4和Django 1.6.我沿着 django-tinymce / django-flatpages-tinymce 路线走了,因为我在其他项目上进行了研究.对于这个新项目,它有些不起作用.我做了一些研究,决定直接使用TinyMCE,没有Django应用程序(例如,没有 django-tinymce django-flatpages-tinymce ).

I've been struggling with TinyMCE recently, as well. I'm using TinyMCE v4 and Django 1.6. I went down the django-tinymce/django-flatpages-tinymce route because I had these working on another project. Some how it wasn't working for this new project. I did some research and decided to just go straight TinyMCE, no Django applications (eg, no django-tinymce or django-flatpages-tinymce).

此方法减少了Django中的所有配置,并且可以在 tinymce.init 调用中完全处理.我发现这比处理Django的设置文件,覆盖模型等要容易得多.只需找到想要TinyMCE进行调味的模板,然后在其中添加 init 调用即可.

This method cuts down on all configuration in Django, and it can be completely handled within the tinymce.init call. I found this much easier than dealing with Django's settings files, overriding models, etc. Just simply find the template you want TinyMCE to spice up and add the init call there.

这里的全功能示例确实对我有帮助:

The example here for full featured example really helped me:

http://www.tinymce.com/tryit/full.php

这使用了现代主题...

This use the modern theme...

我只是将其添加到任何需要丰富编辑器的模型的 change_form.html 模板中.例如平面广告:

I simply added this to whichever change_form.html template for whatever model I was needing the rich editor. For instance for flatpages:

admin/flatpages/flatpage/change_form.html

或在应用中自定义模型:

Or custom model in app:

admin/custom_app/model_name/change_form.html

我知道这确实是您问题的答案,但是我认为这值得考虑,并且可能最终帮助您获得所需的东西.

I know this is exactly an answer to your question, but I think it's worth thinking about and might help you ultimately get what you need.

另外,我应该注意,似乎TinyMCE v4仅提供现代主题:

Also, I should note, it looks like only modern theme is available for TinyMCE v4:

http://www.tinymce.com/wiki.php/Tutorial:Migration_guide_from_3.x

这篇关于django-tinymce现代主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 21:45