Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

browniebroke/django-tinymce4-widget

Repository files navigation

django-tinymce4-widget

CI Status Documentation Status Test coverage pre-commit.ci status

Poetry black pre-commit

PyPi Status pyversions license


Documentation: https://django-tinymce4-widget.readthedocs.io

Source Code: https://github.com/browniebroke/django-tinymce4-widget


Important

The latest version of TinyMCE (at time of writing) is version 6. This package is -and will stay- focused on TinyMCE 4 only. I no longer use this package myself so I have no incentive to keep it up to date. I recommend moving to a maintained alternative like Jazzband or alternatively fork it.

django-tinymce4-widget is a reworked fork of django-tinymce4-lite. It provides a minimal TinyMCE 4 editor widget that can be used in Django forms.

This version does not include any static files, it's using the TinyMCE from the CDN by default.

Compatibility

  • Python: 3.8-3.12
  • Django: 3.2-5.0

Quick Start

Install django-tinymce4-widget:

$ pip install django-tinymce4-widget

Add tinymce to INSTALLED_APPS in settings.py for your Django project:

INSTALLED_APPS = (
    ...
    'tinymce',
)

Add tinymce.urls to urls.py for your project:

urlpatterns = [
    ...
    path('tinymce/', include('tinymce.urls')),
    ...
]

In your code:

from django.db import models
from tinymce import HTMLField

class MyModel(models.Model):
    ...
    content = HTMLField('Content')

In Django Admin the widget is used automatically for all models that have HTMLField fields. If you are using TinyMCE 4 in your website forms, add form.media variable into your templates:

<!DOCTYPE html>
<html>
<head>
  ...
  {{ form.media }}
</head>
<body>
...
</body>
</html>