zoukankan      html  css  js  c++  java
  • Django’s admin html editor — TinyMCE


    get TinyMCE running inside Django's Admin
    1. craete /usr/lib/python2.5/site-packages/django/contrib/admin/media/tiny_mce (for linux)
    2. download TinyMCE (should be like this figure 1)
    3. Configure the TinyMCE pane. In the django/contrib/admin/media/js folder, add a textareas.js file that will initialize and configureTinyMCE.
    4. textareas.js
    5. write a page in model.p
    6. add
    js = ['tiny_mce/tiny_mce.js', 'js/textareas.js'] at the end
    Reference for using js in admin page: http://www.djangoproject.com/documentation/model-api/#j
    class Admin:

    fields = (

    ('Content', {'fields': ('name','position','bio','fote', 'jobcat', 'pageorder')}),
    )

    list_display = ( 'name', 'jobcat' )
    list_filter = ['status', 'jobcat']

    search_fields = ['name']

    js = ['tiny_mce/tiny_mce.js', 'js/textareas.js']

    7. further:The next thing I want to do is install TinyMCE as the default DjangoFlatpage editor;
    that will require patching the existing admin module,and probably adding a flag to settings.py
    to enable/disable it. Itwould be nice too if the setting was global instead of having to markupeach
    model's Admin class. The only way I've seen to do that to date is to create a new model field called RichTextField
    that brings in the js editor by default. But that mixes up content authoring concerns with modelling
    concerns by subclassing forms.TextField, which is why I decided not to go that route. I think hacking
    the Admin module to be wysiwyg configurable is cleaner, the problem is deciding what js tool to bundle.
    In the long run I imagine admin will ship with Dojo editor since Dojo is what the Django guyshave settled
    on (and Dojo editor can deal with the back button as well which is *very* cool).

    Reference:http://www.dehora.net/journal/2006/05/using_tinymce_in_djangos_admin.html
    http://code.djangoproject.com/wiki/AddWYSIWYGEditor

    This entry was posted on December 26, 2007 at 10:28 am

    作者:Buro#79xxd 出处:http://www.cnblogs.com/buro79xxd/ 文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    Servlet介绍(一)
    iOS Dev (50)用代码实现图片加圆角
    Codeforces Round #265 (Div. 2) D. Restore Cube 立方体推断
    JVM:垃圾回收机制和调优手段
    Memcachedclient-XMemcached使用
    JVM中类的卸载机制
    血型统计
    iOS 事件传递及响应过程
    java 对象参数去空格方式
    spring aop 一个挡板例子
  • 原文地址:https://www.cnblogs.com/buro79xxd/p/1682572.html
Copyright © 2011-2022 走看看