3

I am new to django and am trying to use tinymice_3.5.8 to replace the text area of django admin with rich text editor. I have added the url pattern of tinymice in the urls.py file of the site as

url(r'^tiny_mce/(?P<path>.*)$','django.views.static.serve',
{ 'document_root': 'C:/tinymce_3.5.8/tinymce/jscripts/'})

and I have copied the change_form.html file of the django/contrib/admin/templates/admin/ directory to my template directory and added the following code in the file.

<script type="text/javascript"
src="C:/tinymce_3.5.8/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
  mode: "textareas",
  theme: "simple"
});
</script>

after the line

{{media}}

This should have replaced the old text area of the Django site admin, Add flat page, with the rich text editor, but is not showing any changes. The text area remains the same. I have also studied similar questions in this site but could not get anything. Hope to get some help!

Santosh Ghimire
  • 3,087
  • 8
  • 35
  • 63
  • 1
    Does the browser even load javascript file? Im asking since src attribute is a windows path. – Bula Dec 18 '12 at 10:35
  • Look at this [link](http://stackoverflow.com/questions/329963/replace-textarea-with-rich-text-editor-in-django-admin).This link might help you... – Lionel Dec 18 '12 at 10:53
  • @Bula ok, I got it. The issue is with the path. But it is still not working even if I copy the js file to the working directory. – Santosh Ghimire Dec 18 '12 at 12:21
  • Try to copy `langs/en.js` and `themes/simple/editor_template.js` into folder where you have `tiny_mce.js`, leave them in appropriate subfolders. Check if firebug reports any error on the console. – Bula Dec 18 '12 at 14:14

1 Answers1

3

Try this: https://github.com/aljosa/django-tinymce - It's a tinymce module especially for django. You use it like this:

in a models.py:

from tinymce.models import HTMLField

class MyModel(models.Model):
    text = HTMLField()

And it works in the django admin too.

mawimawi
  • 4,222
  • 3
  • 33
  • 52
  • I have created only site using django. There is no app in it. So, there is no models.py file to change. Anyway, thanks for your answer. – Santosh Ghimire Dec 18 '12 at 12:23