{"id":5192,"library":"django-tinymce","title":"Django TinyMCE","description":"django-tinymce is a Django application that provides a widget to easily integrate the TinyMCE rich text editor into Django forms and models. It allows for highly customizable WYSIWYG editing experiences within Django projects, including the admin interface. The library is actively maintained with regular updates to support newer TinyMCE and Django versions.","status":"active","version":"5.0.0","language":"en","source_language":"en","source_url":"https://github.com/jazzband/django-tinymce","tags":["django","tinymce","wysiwyg","rich-text-editor","forms","admin","html-field"],"install":[{"cmd":"pip install django-tinymce","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core framework dependency for the application.","package":"Django"},{"reason":"Requires Python 3.9 or higher.","package":"Python","version":">=3.9"},{"reason":"The JavaScript rich text editor itself. Can be self-hosted or loaded from a CDN.","package":"TinyMCE","optional":false}],"imports":[{"note":"Use this for form fields in `forms.py` or `admin.py` to apply the TinyMCE widget.","symbol":"TinyMCE","correct":"from tinymce.widgets import TinyMCE"},{"note":"Use this as a model field type in `models.py` for content that requires rich text editing.","symbol":"HTMLField","correct":"from tinymce.models import HTMLField"},{"note":"This field is part of `django-ckeditor`, not `django-tinymce`. `django-tinymce` uses `HTMLField` for rich text model fields.","wrong":"from tinymce.models import RichTextUploadingField","symbol":"RichTextUploadingField","correct":"from ckeditor_uploader.fields import RichTextUploadingField"}],"quickstart":{"code":"# settings.py\nimport os\n\nINSTALLED_APPS = [\n    # ...\n    'tinymce',\n]\n\n# Configure TinyMCE (adjust TINYMCE_JS_URL based on self-hosted or CDN)\nTINYMCE_JS_URL = 'https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js' # Example using CDN with no API key\n# OR for self-hosted: TINYMCE_JS_URL = os.path.join(STATIC_URL, 'tinymce/tinymce.min.js')\n\nTINYMCE_DEFAULT_CONFIG = {\n    'height': 360,\n    'menubar': False,\n    'plugins': 'advlist autolink lists link image charmap print preview anchor searchreplace visualblocks code fullscreen insertdatetime media table paste code help wordcount',\n    'toolbar': 'undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help',\n    'custom_undo_redo_levels': 10,\n    'browser_spellcheck': True, # Important for TinyMCE 6+ spellcheck\n}\n\n# urls.py (project level)\nfrom django.contrib import admin\nfrom django.urls import path, include\n\nurlpatterns = [\n    path('admin/', admin.site.urls),\n    path('tinymce/', include('tinymce.urls')), # Required for TinyMCE views\n]\n\n# models.py (your app)\nfrom django.db import models\nfrom tinymce.models import HTMLField\n\nclass MyRichTextModel(models.Model):\n    title = models.CharField(max_length=200)\n    content = HTMLField()\n\n    def __str__(self):\n        return self.title\n\n# admin.py (your app)\nfrom django.contrib import admin\nfrom .models import MyRichTextModel\nfrom tinymce.widgets import TinyMCE\nfrom django import forms\n\nclass MyRichTextAdminForm(forms.ModelForm):\n    content = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))\n\n    class Meta:\n        model = MyRichTextModel\n        fields = '__all__'\n\n@admin.register(MyRichTextModel)\nclass MyRichTextModelAdmin(admin.ModelAdmin):\n    form = MyRichTextAdminForm\n","lang":"python","description":"To quickly set up django-tinymce, first install the package and add 'tinymce' to your `INSTALLED_APPS`. Include `tinymce.urls` in your project's `urls.py`. Then, configure TinyMCE settings in `settings.py`, paying attention to `TINYMCE_JS_URL` for the TinyMCE JavaScript source (either self-hosted or CDN) and `TINYMCE_DEFAULT_CONFIG` for editor options. You can use `tinymce.models.HTMLField` directly in your models or `tinymce.widgets.TinyMCE` in your Django forms or admin definitions to apply the rich text editor."},"warnings":[{"fix":"Remove `spellchecker` from TinyMCE plugins in `TINYMCE_DEFAULT_CONFIG`. Set `'browser_spellcheck': True` instead.","message":"Version 4.0.0 upgraded TinyMCE from v5 to v6. The `spellchecker` plugin was removed; use the `browser_spellcheck` TinyMCE option instead. This requires configuration changes in `TINYMCE_DEFAULT_CONFIG`.","severity":"breaking","affected_versions":"4.0.0+"},{"fix":"Review and update `toolbar` and `plugins` settings in `TINYMCE_DEFAULT_CONFIG` according to TinyMCE 6 documentation and `django-tinymce` release notes.","message":"Following the TinyMCE 6 upgrade in v4.0.0, version 4.1.0 further addressed renamed toolbar elements and removed buttons from premium plugins, potentially breaking existing toolbar configurations.","severity":"breaking","affected_versions":"4.1.0+"},{"fix":"Remove `TINYMCE_INCLUDE_JQUERY` from your `settings.py`. Ensure your project handles jQuery dependencies separately if still needed for other parts of your application.","message":"Version 3.1.0 removed the jQuery dependency. Consequently, the `TINYMCE_INCLUDE_JQUERY` setting was also removed.","severity":"breaking","affected_versions":"3.1.0+"},{"fix":"Ensure your project runs on Python >= 3.7 and Django >= 3.2 to use `django-tinymce` v3.5.0 and newer versions.","message":"Version 3.5.0 dropped support for older Python and Django versions. Specifically, Python 3.6 and Django 3.0, 3.1 are no longer supported.","severity":"breaking","affected_versions":"3.5.0+"},{"fix":"Verify that `TINYMCE_JS_URL` in `settings.py` points to the correct `tinymce.min.js` file (either self-hosted in your static files or a CDN). Ensure Django's static files configuration is correct and that `{{ form.media }}` is included in your template's `<head>` section.","message":"TinyMCE editor may not display correctly (e.g., no toolbar, basic textarea) if `TINYMCE_JS_URL` is incorrect or if static files are not served properly.","severity":"gotcha","affected_versions":"All"},{"fix":"Before submitting the form, ensure that `tinyMCE.triggerSave()` is called. This forces TinyMCE instances to update their corresponding `<textarea>` elements, making their content available for Django to process.","message":"Content edited in TinyMCE might not be saved on form submission, particularly in complex forms or when using custom JavaScript to handle submission.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}