[Answered ]-TinyMCE on Django Form

2👍

You’re adding the editor to the div that wraps the form. You need to add it to specific elements in the form – inputs and text areas. These are identified by the value of the elements option in the TinyMCE.init() function.

Look at customising the form template, and adding your mceEditor class to the elements you want.

Alternatively you could write a little javascript to insert the class, and place it before your current js. Something like –

$('#yourForm textarea').addClass('mceEditor');

(You’ll need to change your template –

<p><div id="yourForm">{{ form.as_p }}</div></p>

so the jquery selector works. Obviously you’ll need to identify which fields you actually want the editor on).

Leave a comment