A rich text editor for a Django configuration app-specific class

Source: Internet
Author: User

Version: django:1.6 python:2.7

  1. Download TinyMCE. http://www.tinymce.com/download/download.php

  2. Extract. Place the TinyMCE folder under the Django static file directory/static/.

  3. 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"
    });

  4. 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.

  5. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.