Django TINYMCE joins SYNTAXHL (syntax highlighting plugin)

Source: Internet
Author: User

First read this article install tinymce:http://blog.csdn.net/dreamzml/article/details/8842409

Then there seems to be one or two ways online, and I'm only saying that one of my successes

1 Download Syntaxhighlighter 3.0.83, unzip the copy to the Django static directory (my is static/)

2 download Syntaxhl, copy to TinyMCE plugin directory (I put it in the static directory and the TinyMCE app directory, must have put one more)

3 The following fields are added to the main settings.py

1 #TINYMCE2Tinymce_js_url='/static/tiny_mce/tiny_mce_src.js'3tinymce_js_root='/static/tiny_mce/'4Tinymce_default_config = {  5 'Plugins':"Table,spellchecker,paste,searchreplace,syntaxhl",6 'Theme':' Advanced',   7 'THEME_ADVANCED_BUTTONS3':'Syntaxhl',8 'theme_advanced_toolbar_location':'Top',  9 'theme_advanced_toolbar_align':' Left',   Ten 'width': 600,   One 'Height': 400,   A }   -Tinymce_spellchecker = True
' Theme_advanced_buttons3 ': ' Syntaxhl ', this line means the button is placed on the third row
4 This step is not sure if you want to
1Template_dirs = (2Os.path.join (Base_dir,'Templates',),3Os.path.join (Base_dir,'Templates/upload',),4Os.path.join (Base_dir,'/static/syntaxhighlighter/styles',),5Os.path.join (Base_dir,'/static/syntaxhighlighter/scripts/',),6)

5 Backstage now models.py inside set tinymce_models. Htmlfield (max_length = 3000) is an estimate to show this.

Notice that the third line of the icon is the one we added.

6 now to show in our view, to add in the view

<Linkhref= "/static/syntaxhighlighter/styles/shcore.css"type= "Text/css"rel= "stylesheet"><Linkhref= "/static/syntaxhighlighter/styles/shthemedjango.css"type= "Text/css"rel= "stylesheet"><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shcore.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushpython.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushxml.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushsql.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushjscript.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushjava.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushcss.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushcpp.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushperl.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushbash.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushcsharp.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushphp.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shbrushperl.js"></Script><Scripttype= "Text/javascript"src= "/static/syntaxhighlighter/scripts/shcore.js"></Script><Scripttype= "Text/javascript">Syntaxhighlighter.all ();</Script>

Note that the path is your own, do not copy, the file has been downloaded in the previous

7 Finally, in the template to write this

{{Each.body|safe}}

Plus safe to display, you can see the Django book

It's almost like that, according to the memory of =-=.

Django TINYMCE joins SYNTAXHL (syntax highlighting plugin)

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.