Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t让TinyMCE在django admin中工作_Django_Django Tinymce - Fatal编程技术网

Can';t让TinyMCE在django admin中工作

Can';t让TinyMCE在django admin中工作,django,django-tinymce,Django,Django Tinymce,我按照中的说明将TinyMCE安装到django管理后端 但它不起作用。在检查控制台日志时,我看到: http://127.0.0.1:8000/media/js/tiny_mce/tiny_mce.js Failed to load 我需要手动添加js文件吗?github中的指令没有提到这一点 更新 事实上,要让它工作,你必须将这个微小的_mce移动到你的静态文件夹中。 这是我为同样有类似问题的人提供的解决方案 settins.py STATIC_URL = '/static/' STAT

我按照中的说明将TinyMCE安装到django管理后端

但它不起作用。在检查控制台日志时,我看到:

http://127.0.0.1:8000/media/js/tiny_mce/tiny_mce.js Failed to load 
我需要手动添加js文件吗?github中的指令没有提到这一点

更新

事实上,要让它工作,你必须将这个微小的_mce移动到你的静态文件夹中。 这是我为同样有类似问题的人提供的解决方案

settins.py
STATIC_URL = '/static/'
STATIC_ROOT = ''
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)
#this is for localhost development, if you are in production enviroment, you will need to remove the STATICFILES_DIRS and define your STATIC_ROOT
 TINYMCE_DEFAULT_CONFIG = {
 'plugins' : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,pagebreak",
'theme': "advanced",

'theme_advanced_buttons1' : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect,fullscreen,code,|,preview,image,media",
'theme_advanced_buttons2' : "table,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,|,forecolor,backcolor, emotions,|,pagebreak,paste",
'theme_advanced_buttons3 ': "",
'theme_advanced_toolbar_location' : "top",
'theme_advanced_toolbar_align' : "left",
'width': '700',
'height': '400'
}


admin.py
class AdminPost(admin.ModelAdmin):
    class Media:
                js = ('/static/js/tiny_mce/tiny_mce.js',)

这个问题有两个可能的原因

1.)您拥有所需的文件,但位置与脚本标记中指定的位置不同。将脚本标记中的url更改为有效位置,它将起作用


2.)您没有所需的文件。下载源文件并将其放置在指定的位置,它就会工作。

Django TinyMCE将媒体url作为默认值,如您在文档中看到的:

TINYMCE_JS_URL (default: settings.MEDIA_URL + 'js/tiny_mce/tiny_mce.js')
TINYMCE_JS_ROOT (default: settings.MEDIA_ROOT + 'js/tiny_mce')
如果希望使用静态文件夹中的静态文件,则必须将这些值设置为正确的路径。我建议:

TINYMCE_JS_URL = settings.STATIC_URL + 'js/tiny_mce/tiny_mce.js'
TINYMCE_JS_ROOT = settings.STATIC_ROOT + 'js/tiny_mce'
现在,您必须确保在staticfiles\u finders设置中使用“django.contrib.staticfiles.finders.AppDirectoriesFinder”,以便不必在开发环境中复制文件,也不必使用collectstatic收集文件。

您应该尝试:-

  • 首先卸载tinymce

    pip卸载django-tinymce4

  • 然后重新安装tinymce


  • 它对我有用

    检查静态文件夹的权限,并在媒体中复制微型文件夹。