Django中使用tiny_mce

1、在django项目的settings.py中添加 STATIC_PATH = './static', 并在urls.py的urlpatterns加入

(r'^static/(?P<path>.*),'django.views.static.serve',{'document_root':settings.STATIC_PATH}),  #注意别掉了这里的逗号

2、在前台模板页面<head></head>之间加入

<script type="text/javascript" src="/static/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="/static/tiny_mce/textareas.js"></script>

admin后台,在Python26/Lib/site-packages/django/contrib/admin/templates/admin目录中的base.html 同样加入上面2行代码。

3、前台界面以及admin后台管理处<textarea ></textarea>标签自动添加有TinyMCE编辑器。

*如非django 项目,在第3步之后在需要的页面引入tiny_mce.js、textareas.js即可。

 

ps:

確定http://127.0.0.1:8000/static/tiny_mce/textareas.js可以訪問

csdn blog裡也是用的tiny_mce, tiny_mce的配置如下:

    tinyMCE.init({
mode: "textareas",
theme: "advanced",
plugins: "syntaxhl,safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,iespell,insertdatetime,preview,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,inlinepopups",
// Theme options
theme_advanced_buttons1: "styleprops,formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,blockquote,|,forecolor,backcolor",
theme_advanced_buttons2: "advhr,|,newdocument,|,cut,copy,paste,pastetext,pasteword,|,search,replace,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,syntaxhl,|,hr,removeformat,visualaid,|,sub,sup,|,insertdate,inserttime,preview,|,fullscreen",
theme_advanced_buttons3: "",
theme_advanced_buttons4: "",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true,
remove_linebreaks: false,
extended_valid_elements: "textarea[cols|rows|disabled|name|readonly|class]",
content_css: "http://hi.images.csdn.net/js/blog/tiny_mce/css/word.css",
language: "zh"

});

 

你可能感兴趣的:(python,django,Path,Safari,plugins,tinymce)