A Django app to integrate Jodit WYSIWYG editor with support for admin and forms
Project description
django-jodit
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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ffcd071485c1461991609449c11fb2950ab467d466bdd399cdd1a7c434a144d
|
|
| MD5 |
b7bf042be578a8b3f6bf47a6b9c736c9
|
|
| BLAKE2b-256 |
5d31de5ae367b728c622ff7d7a6cbc46baded5e05ac4377e403fcae1b53610c3
|
Provenance
The following attestation bundles were made for django_jodit-0.1.0.tar.gz:
Publisher:
ci.yml on mounirmesselmeni/django-jodit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_jodit-0.1.0.tar.gz -
Subject digest:
7ffcd071485c1461991609449c11fb2950ab467d466bdd399cdd1a7c434a144d - Sigstore transparency entry: 699562940
- Sigstore integration time:
-
Permalink:
mounirmesselmeni/django-jodit@68a9aa315c6e74ee1a711eb43b76a1dca29021f3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mounirmesselmeni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@68a9aa315c6e74ee1a711eb43b76a1dca29021f3 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c10b80ee56adf6a6b36fc18c86781fe891930394b7d738441eca6d18e25d0fbf
|
|
| MD5 |
894bac7568db756d9a3abfc0395383d0
|
|
| BLAKE2b-256 |
d1bb53ba645b3164a0d5c267137871a00c3340cafd411d659dd891a8c7137a4c
|
Provenance
The following attestation bundles were made for django_jodit-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on mounirmesselmeni/django-jodit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_jodit-0.1.0-py3-none-any.whl -
Subject digest:
c10b80ee56adf6a6b36fc18c86781fe891930394b7d738441eca6d18e25d0fbf - Sigstore transparency entry: 699562944
- Sigstore integration time:
-
Permalink:
mounirmesselmeni/django-jodit@68a9aa315c6e74ee1a711eb43b76a1dca29021f3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mounirmesselmeni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@68a9aa315c6e74ee1a711eb43b76a1dca29021f3 -
Trigger Event:
release
-
Statement type: