我将 TinyMCE(直接,而不是 django-tinymce)和 django-filebrowser 添加到 django admin。它可以工作,除了一件事:然后我单击 Tiny“添加图片”菜单上的文件浏览按钮,我得到 Page not found (404),因为我不明白 Tiny 选项中这个字符串的含义:
var managerURL = window.location.toString()
+ 'media/upload/?type=' + type;
完整代码:
<script type="text/javascript">
function tinyDjangoBrowser(field_name, url, type, win) {
var managerURL = window.location.toString()
+ 'media/upload/?type=' + type;
tinyMCE.activeEditor.windowManager.open({
file: managerURL,
title: 'Pic',
width: 800,
height: 450,
resizable: 'yes',
inline: 'yes',
close_previous: 'no',
popup_css : false
}, {
window: win,
input: field_name
});
return false;
}
tinyMCE.init({
mode : "specific_textareas",
theme : "advanced",
skin : "bootstrap",
plugins : "safari,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",
extended_valid_elements : 'script[type|src],iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],div[*],p[*],object[width|height|classid|codebase|embed|param],param[name|value],embed[param|src|type|width|height|flashvars|wmode]',
media_strict: false,
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,print,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
file_browser_callback: 'tinyDjangoBrowser',
relative_urls : "false",
remove_script_host : false,
convert_urls : false
});
</script>
请告诉我,在我的情况下应该如何?
还有一件事:我需要连接 tiny_mce_popup.js 吗?对不起,我的英语不好。谢谢!