Santosh Ghimire
Santosh Ghimire

Reputation: 3145

Using Rich Text Editor in Django admin with tinymice

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!

Upvotes: 3

Views: 3836

Answers (1)

mawimawi
mawimawi

Reputation: 4353

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.

Upvotes: 3

Related Questions