Version: django:1.6 python:2.7
Download TinyMCE. http://www.tinymce.com/download/download.php
Extract. Place the TinyMCE folder under the Django static file directory/static/.
-
Already has tinymce.min.js this JS file in the TinyMCE folder; What we need to do is to create a new tinymce_config.min.js in the current directory (with the tinymce.min.js sibling):
The content is populated as follows:
Tinymce.init ({
selector: "TextArea",
theme: "Modern",
plugins: [
"Advlist autolink lists link image charmap print preview hr anchor PageBreak",
searchreplace WordCount Vis Ualblocks visualchars code fullscreen ",
" InsertDateTime Media nonbreaking save Table ContextMenu Directionality ",
" Emoticons template paste TextColor "
],
toolbar1:" InsertFile undo Redo | Styleselect | Bold Italic | AlignLeft aligncenter alignright alignjustify | Bullist numlist outdent Indent | Link image,
toolbar2: "Print Preview Media | ForeColor BackColor Emoticons ",
image_advtab:true,
visualblocks_default_state:true,
width:1000,
height:400,
//content_css: "/static/blog/css/tinymce.css"
});
Go to tinymce/skins/lightgray/, modify the Skin.min.css file, find the. mce-tinymce section, add a margin-left parameter, and change to. Mce-tinymce{visibility: Visible!important;margin-left:100px; Position:relative}, you can move the editor right 100px to reveal the Label.
Add the following code below the class models.py to display the Rich Text editor:
Class Articleadmin (admin. Modeladmin):
list_display= ("id", "Title", "Author", "CreateDate",)
search_fields= ("Title",)
Class Media:
js=[' tinymce/tinymce.min.js ', ' tinymce/tinymce_config.min.js ']
6. Complete.
Finally say, different environment certainly have how many difference, find the right idea, that can complete the function that you want.
This article is from the "Blue Fin Dolphin" blog, please be sure to keep this source http://likunheng.blog.51cto.com/9527645/1596177
A rich text editor for a Django configuration app-specific class