Django’s admin html editor — TinyMCE
Labels:
Django
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 endReference for using js in admin page: http://www.djangoproject.com/documentation/model-api/#j7. further:The next thing I want to do is install TinyMCE as the default DjangoFlatpage editor;
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']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/
文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架