2013-03-04 106 views
1

我添加了TinyMCE(直接,而不是django-tinymce)和Django文件瀏覽器到Django的管理員。它的工作原理,除了一兩件事: 然後我點擊微小的「添加圖片」菜單上的文件瀏覽按鈕,我得到找不到網頁(404),因爲我不明白是什麼意思此字符串微小選項:Django + Django的文件瀏覽器+ TinyMCE

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?對不起,我的英語不好。謝謝!

+0

你能記錄這到你的控制檯嗎? window.location.toString() +'media/upload /?type ='+ type。你會得到什麼網址? – Thariama 2013-03-04 09:34:04

+0

http://127.0.0.1:8000/admin/auto/blogmain/2/media/upload/?type=image我知道這是絕對錯誤的,但我不明白它應該是什麼。 – Wolter 2013-03-04 09:47:45

回答

1

我找到了!在我的情況下,它應該是

var managerURL = '/admin/filebrowser/browse/?pop=2'