Django and TinyMce
Published Wed Jul 27th 2005 in Django PythonI have been experimenting with the Django web framework for the past few days and it is great. It is easy to learn, and what it produces from the amount of code you input is staggaring.
One thing I did find lacking was lack of a wysisyg input field. meta.TextField works great but sometimes users need a little more. At first I wanted to create a meta.HtmlField but after some more thought you can achieve the same results with a meta.TextField and the admin.js param. Before I get into the code here is a screenshot of what we will achieve.
Here's how:
First you will need to download the TinyMce code from http://tinymce.moxiecode.com/download.php
Extract that to somewhere on your system. I used /Users/jay/Sites/javascript
Next you will need to link the TinyMce code into the Django media directory
ln -s /Users/jay/javascript/tinymce/jscripts/tiny_mce /Users/jay/python/django/trunk/django/conf/admin_media/js/tiny_mce
djang-admin.py runserver --settings=myproject.settings.admin
tinyMCE.init({
mode : "textareas",
theme : "default"
});fields = (
meta.CharField('title','title',maxlength=200),
meta.TextField('description','description'),
meta.CharField('location','location',maxlength=200)
)
admin = meta.Admin(
fields = (
(None, {'fields': ('title','description','location')}),
),
js = ('/media/js/tiny_mce/tiny_mce.js','/media/js/tiny_mce/textareas.js'),
)
Latest
Xbox Live Gamercard
-
Develop Denver @dvlpdnvr looks cool. http://t.co/hX3GVEUkSnow covered skylights give the @doubleencore office a weird glow this morning. (at @doubleencore) [pic] — http://t.co/YaUzBsOkToday @doubleencore I.. Shipped an app Setup our 5th build server Played a game Played with TV & Airplay Now hiring http://t.co/I9UPTNu3Terminal has an icon with white text on a dark bkgrnd. The default Terminal window is black text on a white bkgrnd Why? http://t.co/AyJDZZK7What ever happened to Burnout Crash for iOS. http://t.co/OjKCdJ8r Wasn't that supposed to be out last year?I spent some time today sitting at my desk playing video games. Because it's my job :)DESCENDENTS (at Fillmore Auditorium) — http://t.co/CMoFYGQ4I just earned the 'I Believe in IPA! (Level 2)' badge on @untappd from Hoptopia! http://t.co/2Xzkbhx2 #ibelieveinIPASuck it Carl! (with Nick at Yazoo BBQ Company) [pic] — http://t.co/Dk7qV8i9
