admin.py
from django.contrib import admin
from django.contrib.admin import widgets
@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
change_form_template = "tinymce/change_form.html"
change_list_template = "tinymce/change_list.html"
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'comments':
kwargs['widget'] = widgets.AdminTextareaWidget()
tinymce/change_form.html
{% extends 'admin/change_form.html' %}
{% block extrahead %}
{{ block.super }}
{% include "tinymce/include/head.html" %}
{% endblock %}
{% block content %}
{{ block.super }}
{% include "tinymce/include/script.html" %}
{% endblock %}
tinymce/change_list.html
{% extends 'admin/change_list.html' %}
{% block extrahead %}
{{ block.super }}
{% include "tinymce/include/head.html" %}
{% endblock %}
{% block content %}
{{ block.super }}
{% include "tinymce/include/script.html" %}
{% endblock %}
tinymce/include/head.html
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
tinymce/include/script.html
<script>
tinymce.init({
selector: 'textarea.vLargeTextField', <!-- One single editor for all textareas -->
width: 600,
height: 100,
max_height: 300,
autoresize_bottom_margin: 0,
resize: true,
menubar: false,
toolbar: false,
statusbar: false,
branding: false,
plugins: 'autoresize quickbars lists table autolink help',
quickbars_insert_toolbar: false,
quickbars_selection_toolbar: 'bold italic underline strikethrough | bullist numlist | blockquote',
contextmenu: 'undo redo | inserttable | cell row column deletetable | help',
});
</script>