三 Django 1.5.4 TinyMCE
来源:互联网 发布:c#管理系统界面源码 编辑:程序博客网 时间:2024/05/02 06:12
一.安装
详见http://hackedexistence.com/project/django/video4-tinymce.html
pip install django-tinymcepip install PIL INSTALLED_APPS = ( ... 'tinymce',)urlpatterns = patterns('', ... (r'^tinymce/', include('tinymce.urls')),)from django.db import modelsfrom tinymce.models import HTMLFieldclass MyModel(models.Model): ... content = HTMLField()
二.pages app
./manage.py startapp pages
三.修改pages/models.py
from django.db import models# Create your models here.class HomePage(models.Model): homecopy =models.TextField() def __unicode__(self): return 'Home Page Copy'
将tinymce 的内容复制到static/js/tiny_mce/下面
添加textarea.js
tinyMCE.init({ // General options mode : "textareas",theme : "advanced",plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,nonedita ble,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",// Theme optionstheme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect,fullscreen,code",theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,|,forecolor,backcolor",theme_advanced_buttons3 : "tablecontrols,|,hr,sub,sup,|,charmap",theme_advanced_toolbar_location : "top",theme_advanced_toolbar_align : "left",theme_advanced_statusbar_location : "bottom",theme_advanced_resizing : true,// Example content CSS (should be your site CSS)//content_css : "/css/style.css",template_external_list_url : "lists/template_list.js",external_link_list_url : "lists/link_list.js",external_image_list_url : "lists/image_list.js",media_external_list_url : "lists/media_list.js",// // Style formatsstyle_formats : [{title : 'Bold text', inline : 'strong'},{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},{title : 'Help', inline : 'strong', classes : 'help'},{title : 'Table styles'},{title : 'Table row 1', selector : 'tr', classes : 'tablerow'}], width: '700', height: '400' });
四.修改pages/admin.py
from django.contrib import adminfrom pages.models import HomePageclass TinyMCEAdmin(admin.ModelAdmin): class Media: js=('/static/js/tiny_mce/tiny_mce.js','/static/js/tiny_mce/textareas.js',)admin.site.register(HomePage,TinyMCEAdmin)
五.修改pages/views.py
# Create your views here.from django.shortcuts import render_to_responsefrom django.template import RequestContextfrom pages.models import HomePagedef MainHomePage(request): homepage =HomePage.objects.get(pk=1) context ={'homepage':homepage} return render_to_response('index.html',context,context_instance=RequestContext(request))
六.修改urls.py
(r'^$','pages.views.MainHomePage'),
七.修改templates/index.html\
{% extends "base.html" %}{% block content %} <div id="home_copy"> {{ homepage.homecopy|safe }} </div> <a href="/beers/">View the Beers list!</a>{% endblock %}
- 三 Django 1.5.4 TinyMCE
- django安装tinymce
- django中如何使用tinymce
- django-tinymce django支持富文本编辑器
- django + TinyMCE 实现富文本编辑器
- Django-- Tinymce在线编辑器的使用
- django-tinymce 支持富文本编辑器
- 在Django中使用最新版tinymce
- Django 1.6 配置自定义grappelli-tinyMce
- 为Django添加富文本编辑器TinyMCE
- Django Admin安装可视化编辑器TinyMCE
- Django Admin 使用 TinyMCE 富文本编辑器
- django-tinymce 支持富文本编辑器
- Django整合TinyMCE富文本编辑器
- Django后台整合TinyMCE富文本编辑器
- TinyMCE
- Django admin中使用Django-tinymce富文本编辑框
- Django中扩展TinyMCE使其支持图片上传功能
- hdu 2609 How many
- NSUserDefaults
- 机房收费总结之——Excel表格的导出
- 开始学android--LinearLayout布局
- Android开发之Eclipse快捷键大全
- 三 Django 1.5.4 TinyMCE
- 13年上海先锋商泰试题总结
- 专业学习成果
- B - 又见LKity(kmp)
- 机房收费系统(2)——组合查询
- 杂感
- OCP-1Z0-053-V12.02-603题
- android组件之ScrollView
- Deep learning with word2vec and gensim