简体   繁体   English

文件浏览器未显示在Django-tinymce中

[英]File browser not showing in Django-tinymce

I've been trying to get django-filebrowser working in django-tinymce (using MCE v4.0.x) for a while now, and still can't get the file browser callback to work. 我一直在尝试使django-filebrowserdjango-tinymce (使用MCE v4.0.x)已有一段时间了,但仍然无法使文件浏览器回调正常工作。 Here's what I've done so far: 到目前为止,这是我所做的:

  1. Installed TinyMCE via pip, added necessary settings including the following default config: 通过pip安装TinyMCE,添加了必要的设置,包括以下默认配置:

    TINYMCE_DEFAULT_CONFIG = { 'theme': 'modern', 'relative_urls': False, 'plugins': 'image', }

  2. Used TinyMCE as a widget in one of my forms, like so: 在我的一种表单中将TinyMCE用作小部件,如下所示:

    content = forms.CharField(widget=TinyMCE(attrs={'cols': 100, 'rows': 30}))

  3. Installed filebrowser ( pip install django-filebrowser ), added it to INSTALLED_APPS . 安装了filebrowser( pip install django-filebrowser ),并将其添加到INSTALLED_APPS Also added the setting TINYMCE_FILEBROWSER=True to settings, along with the necessary filebrowser settings. 还添加了设置TINYMCE_FILEBROWSER=True至设置,以及必需的文件浏览器设置。

I now have the result that a file browser button appears in the 'add image' dialog in TinyMCE, but when I click it I get the following error in my browser's JS console: 我现在得到的结果是,文件浏览器按钮出现在TinyMCE的“添加图像”对话框中,但是当我单击它时,在浏览器的JS控制台中出现以下错误:

Uncaught TypeError: string is not a function

I also get the following Javascript error about loading the filebrowser plugin: 我还收到有关加载filebrowser插件的以下Javascript错误:

Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR) http://localhost:8080/tinymce/filebrowser/

The only way I have managed to get filebrowser working with MCE v.4 is with a fork of Django-tinymce-filebrowser: 我设法使Filebrowser与MCE v.4一起工作的唯一方法是使用Django-tinymce-filebrowser的fork:

https://github.com/philroche/Django-tinymce-filebrowser https://github.com/philroche/Django-tinymce-filebrowser

I don't think django-filebrowser supports TinyMCE v.4, as per this reference: https://github.com/sehmaschine/django-filebrowser/pull/219 我不认为django-filebrowser支持TinyMCE v.4,根据此参考: https : //github.com/sehmaschine/django-filebrowser/pull/219

Perhaps there are some forks of django-filebrowser that do. 也许有一些django-filebrowser的分支。

“字符串不是函数”错误是因为“ mce_filebrowser”位于init函数内的引号中。它正在查找脚本。首先请确保该引号不在引号中(在脚本init中,而不是在seetings.py中,其中是的,它应该是一个字符串值),然后确保已链接到静态文件中的脚本文件或项目中要存储.js脚本的任何位置。

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

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