jango-tinymce django支持富文本编辑器



jango-tinymce django支持富文本编辑器。

流程大致如下:

1:下载最新版本的tinymce

2:解压然后把tinymce放到你的meida目录下,我放在media下的js文件夹里(media和js如果没有自己创建),结构下:

 

 

 

 


 

3:编辑urls.py,在urlpatterns中添加(r’^site_media/(?P<path>.*)$’, ‘django.views.static.serve’,    {‘document_root’: ‘media’})

4:在PostAdmin设置js的路径

5:在js下添加textareas.js,其内容为:

 

[javascript:showcolumns] view plaincopy

·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
  1. tinyMCE.init({
  2.     // General options
  3.     mode : “textareas”,
  4.     theme : “advanced”,
  5.     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”,
  6.     // Theme options
  7.     theme_advanced_buttons1 : “save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect,fullscreen,code”,
  8.     theme_advanced_buttons2 : “cut,copy,paste,pastetext,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,|,insertdate,inserttime,preview,|,forecolor,backcolor”,
  9.     theme_advanced_buttons3 : “tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl”,
  10.     theme_advanced_toolbar_location : “top”,
  11.     theme_advanced_toolbar_align : “left”,
  12.     theme_advanced_statusbar_location : “bottom”,
  13.     theme_advanced_resizing : true,
  14.     // Example content CSS (should be your site CSS)
  15.     //content_css : “/css/style.css”,
  16.     template_external_list_url : “lists/template_list.js”,
  17.     external_link_list_url : “lists/link_list.js”,
  18.     external_image_list_url : “lists/image_list.js”,
  19.     media_external_list_url : “lists/media_list.js”,
  20.     // Style formats
  21.     style_formats : [
  22.         {title : 'Bold text', inline : 'strong'},
  23.         {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
  24.         {title : 'Help', inline : 'strong', classes : 'help'},
  25.         {title : 'Table styles'},
  26.         {title : 'Table row 1', selector : 'tr', classes : 'tablerow'}
  27.     ],
  28.     width: ’700′,
  29.     height: ’400′
  30. });

 

 

然后运行django内嵌的服务器,就ok了!!!!