Aleksandr Aleksandr - 6 months ago 33
Python Question

django: disable tinymce for one certain field

I have a lot of models with tinymce(django-tinymce) enabled by default for TextFields and this is ok.
But for one field I don't want to apply tinymce widget (in admin interface).
Please tell me how do I implement that?

class Page(models.Model):
one = models.TextField()
two = models.TextField()
three = models.TextField()

Answer

Yes, In your TinyMCE.init(), you would do:

tinyMCE.init({
        ...
        editor_deselector : "mceNoEditor"
});

and add the class mceNoEditor to the textarea you want to disable tinymce on.

Here is the relevant documentation

In your example, if you want to disable it on three,

three = models.TextField(widget=form.Textarea(attrs={"class": "mceNoEditor"}))
Comments