Skip to main content

A Django app to integrate Jodit WYSIWYG editor with support for admin and forms

Project description

django-jodit

PyPI version Python Version Django Version License: MIT Tests Coverage

A Django app to easily integrate the Jodit WYSIWYG editor into Django forms and admin.

๐ŸŽฅ Live Demo

Check out the example project to see django-jodit in action!

Features

  • ๐ŸŽจ Full-featured WYSIWYG editor with Jodit
  • ๐Ÿ“ Easy integration with Django forms and admin
  • โš™๏ธ Highly configurable through Django settings
  • ๐ŸŽฏ Model field and form field support
  • ๐Ÿ“ฆ Includes all necessary static files (CSS/JS)
  • ๐Ÿ”ง Custom configuration per field
  • ๐ŸŒ Multi-language support

Installation

From PyPI (Recommended)

pip install django-jodit
uv add jodit

From Source

pip install git+https://github.com/mounirmesselmeni/django-jodit.git

Local Development

git clone https://github.com/mounirmesselmeni/django-jodit.git
cd django-jodit
pip install -e .

Quick Start

1. Add to INSTALLED_APPS

Add 'jodit' to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    ...
    'jodit',
    ...
]

2. Configure (Optional)

Add custom Jodit configurations to your settings.py:

JODIT_CONFIGS = {
    'default': {
        'height': 400,
        'width': '100%',
        'toolbar': True,
        'buttons': [
            'source', '|',
            'bold', 'italic', 'underline', '|',
            'ul', 'ol', '|',
            'font', 'fontsize', 'brush', 'paragraph', '|',
            'image', 'table', 'link', '|',
            'align', 'undo', 'redo', '|',
            'hr', 'eraser', 'fullsize',
        ],
    },
    'simple': {
        'height': 200,
        'toolbar': True,
        'buttons': ['bold', 'italic', 'underline', 'link'],
    },
}

Usage

In Models

from django.db import models
from jodit.fields import RichTextField

class Article(models.Model):
    title = models.CharField(max_length=200)
    content = RichTextField()  # Uses 'default' config
    summary = RichTextField(config_name='simple')  # Uses 'simple' config

In Forms

from django import forms
from jodit.fields import RichTextFormField

class ArticleForm(forms.Form):
    content = RichTextFormField()
    summary = RichTextFormField(config_name='simple')

In Admin

The widget will automatically be used in the Django admin for RichTextField fields:

from django.contrib import admin
from .models import Article

@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
    list_display = ['title']

Using the Widget Directly

from django import forms
from jodit.widgets import JoditWidget

class MyForm(forms.Form):
    content = forms.CharField(widget=JoditWidget(config_name='default'))

Dark Theme Support ๐ŸŒ™

Django-Jodit automatically detects and supports dark mode!

Auto-Detection

By default, the editor automatically detects:

  • โœ… Django admin dark mode (data-theme="dark")
  • โœ… Custom dark mode classes

Configuration

JODIT_CONFIGS = {
    'default': {
        'theme': 'auto',  # Auto-detect (default)
    },
    'dark': {
        'theme': 'dark',  # Force dark theme
    },
    'light': {
        'theme': 'default',  # Force light theme
    },
}

The editor dynamically updates when you switch themes in Django admin!

Custom Jodit Versions ๐Ÿ“ฆ

Use different Jodit versions by specifying custom URLs:

Use CDN

# settings.py

# Use specific version
JODIT_JS_URL = 'https://unpkg.com/jodit@4.7.9/es2021/jodit.min.js'
JODIT_CSS_URL = 'https://unpkg.com/jodit@4.7.9/es2021/jodit.min.css'

# Or use latest (not recommended for production)
JODIT_JS_URL = 'https://unpkg.com/jodit@latest/es2021/jodit.min.js'
JODIT_CSS_URL = 'https://unpkg.com/jodit@latest/es2021/jodit.min.css'

Use Local Custom Files

# settings.py
JODIT_JS_URL = '/static/custom/jodit.min.js'
JODIT_CSS_URL = '/static/custom/jodit.min.css'

Use Bundled Version (Default)

# No configuration needed - uses bundled Jodit 4.7.9
# Or explicitly set to None
JODIT_JS_URL = None
JODIT_CSS_URL = None

Configuration Options

The Jodit editor supports many configuration options. Here are some common ones:

JODIT_CONFIGS = {
    'default': {
        # Editor dimensions
        'height': 400,
        'width': '100%',

        # Toolbar settings
        'toolbar': True,
        'toolbarButtonSize': 'middle',  # small, middle, large
        'toolbarAdaptive': True,

        # Editor behavior
        'spellcheck': True,
        'language': 'auto',  # or specific language code
        'askBeforePasteHTML': True,
        'askBeforePasteFromWord': True,

        # UI elements
        'showCharsCounter': True,
        'showWordsCounter': True,
        'showXPathInStatusbar': False,

        # Image handling
        'uploader': {
            'insertImageAsBase64URI': True,
        },

        # Custom buttons
        'buttons': [
            'source', '|',
            'bold', 'italic', 'underline', 'strikethrough', '|',
            'ul', 'ol', '|',
            'outdent', 'indent', '|',
            'font', 'fontsize', 'brush', 'paragraph', '|',
            'image', 'table', 'link', '|',
            'align', 'undo', 'redo', '|',
            'hr', 'eraser', 'copyformat', '|',
            'symbol', 'fullsize', 'print',
        ],
        'removeButtons': [],  # List of buttons to remove
    },
}

For a complete list of configuration options, see the Jodit documentation.

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/mounirmesselmeni/django-jodit.git
cd django-jodit

# Install dependencies
uv sync --dev

Running Tests

# Run tests with coverage
uv run python manage.py test jodit

# Or with coverage report
uv run coverage run --source='jodit' manage.py test jodit
uv run coverage report
uv run coverage html  # Generate HTML report

Code Quality

# Format code
uv run ruff format .

# Lint code
uv run ruff check .

# Install pre-commit hooks
uv run pre-commit install

Project Structure

django-jodit/
โ”œโ”€โ”€ jodit/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ apps.py
โ”‚   โ”œโ”€โ”€ configs.py          # Default Jodit configurations
โ”‚   โ”œโ”€โ”€ fields.py           # RichTextField and RichTextFormField
โ”‚   โ”œโ”€โ”€ models.py
โ”‚   โ”œโ”€โ”€ settings.py         # Settings utilities
โ”‚   โ”œโ”€โ”€ widgets.py          # JoditWidget
โ”‚   โ”œโ”€โ”€ tests.py            # Test suite
โ”‚   โ”œโ”€โ”€ testsettings.py     # Test Django settings
โ”‚   โ”œโ”€โ”€ static/
โ”‚   โ”‚   โ””โ”€โ”€ jodit/
โ”‚   โ”‚       โ”œโ”€โ”€ jodit.min.js
โ”‚   โ”‚       โ”œโ”€โ”€ jodit.min.css
โ”‚   โ”‚       โ””โ”€โ”€ jodit-init.js
โ”‚   โ””โ”€โ”€ templates/
โ”‚       โ””โ”€โ”€ jodit/
โ”‚           โ””โ”€โ”€ widget.html
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ MANIFEST.in
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ manage.py
โ””โ”€โ”€ pyproject.toml

Screenshots

Django Admin Integration

The Jodit editor seamlessly integrates with Django admin, providing rich text editing capabilities out of the box.

Custom Forms

Use Jodit in your custom forms with full control over configuration and styling.

Multiple Configurations

Different editor configurations for different use cases - full-featured editor for main content, simple editor for excerpts and comments.

Example Project

A complete example project is included in the example_project/ directory. It demonstrates:

  • โœ… Blog application with posts and comments
  • โœ… Django admin integration
  • โœ… Multiple editor configurations
  • โœ… Frontend forms with Jodit
  • โœ… Rich text content display

Running the Example

cd example_project
./setup.sh
python manage.py runserver

Visit http://127.0.0.1:8000/ to see it in action!

Jodit Version

This package includes Jodit Editor version 4.7.9.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

Changelog

0.1.0 (2025-11-13)

  • Initial release
  • Basic Jodit editor integration (v4.7.9)
  • Model field and form field support
  • Django admin integration
  • Configurable through Django settings
  • Comprehensive test suite (96% coverage)
  • Example project with blog application
  • GitHub Actions CI/CD with PyPI publishing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_jodit-0.1.0.tar.gz (267.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_jodit-0.1.0-py3-none-any.whl (269.2 kB view details)

Uploaded Python 3

File details

Details for the file django_jodit-0.1.0.tar.gz.

File metadata

  • Download URL: django_jodit-0.1.0.tar.gz
  • Upload date:
  • Size: 267.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_jodit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7ffcd071485c1461991609449c11fb2950ab467d466bdd399cdd1a7c434a144d
MD5 b7bf042be578a8b3f6bf47a6b9c736c9
BLAKE2b-256 5d31de5ae367b728c622ff7d7a6cbc46baded5e05ac4377e403fcae1b53610c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_jodit-0.1.0.tar.gz:

Publisher: ci.yml on mounirmesselmeni/django-jodit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_jodit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_jodit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 269.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_jodit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c10b80ee56adf6a6b36fc18c86781fe891930394b7d738441eca6d18e25d0fbf
MD5 894bac7568db756d9a3abfc0395383d0
BLAKE2b-256 d1bb53ba645b3164a0d5c267137871a00c3340cafd411d659dd891a8c7137a4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_jodit-0.1.0-py3-none-any.whl:

Publisher: ci.yml on mounirmesselmeni/django-jodit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page