| 1 | Download [http://www.dojotoolkit.org Dojo] (kitchen sink) and save it as /media/dojo/... |
| 2 | |
| 3 | Save the following script as AddRichTextEditing.js into /media/js/admin/ |
| 4 | |
| 5 | {{{ |
| 6 | document.write('<script type="text/javascript" src="/media/dojo/dojo.js"></script>'); |
| 7 | document.write('<script type="text/javascript">dojo.require("dojo.widget.Editor2");</script>'); |
| 8 | |
| 9 | var AddEditor = { |
| 10 | init: function() { |
| 11 | var helptext = document.getElementsByTagName('p'); |
| 12 | for (var i = 0, ht; ht = helptext[i]; i++) { |
| 13 | if (ht.firstChild.data == "Rich Text Editing.") { |
| 14 | ht.previousSibling.previousSibling.setAttribute("dojoType", "Editor2"); |
| 15 | } |
| 16 | } |
| 17 | }, |
| 18 | } |
| 19 | |
| 20 | addEvent(window, 'load', AddEditor.init); |
| 21 | }}} |
| 22 | |
| 23 | This script looks for the help text "Rich Text Editing." and replaces the textarea before with the Dojo-Editor. |
| 24 | |
| 25 | Define your model like this: |
| 26 | |
| 27 | {{{ |
| 28 | body = models.TextField('Body', help_text='Rich Text Editing.', blank=True, null=True) |
| 29 | ... |
| 30 | class Admin: |
| 31 | js = ['js/admin/AddRichTextEditing.js'] |
| 32 | }}} |
| 33 | |
| 34 | that´s it. |
| 35 | |
| 36 | result could look like |
| 37 | |
| 38 | [http://www.vonautomatisch.at/django/dojoeditor.jpg Screenshot (Preview)] |