Django widget for CodeMirror 6 with syntax highlighting
Project description
django-codemirror-editor
A Django widget that integrates CodeMirror 6 into Django forms and admin as a drop-in replacement for standard textarea fields.
Features
- CodeMirrorWidget - Form widget that renders textareas with CodeMirror 6
- AdminCodeMirrorWidget - Specialized widget with admin-specific styling
- CodeMirrorField - Model field (
TextField) that automatically uses CodeMirror in forms - Language support - HTML, CSS, and JavaScript syntax highlighting
- Formset support - Works with Django admin inlines and dynamically added forms
- content-editor plugin - Integrates with django-content-editor activation/deactivation events
Requirements
- Python 3.10+
- Django 4.2+
Installation
pip install django-codemirror-editor
Add to your INSTALLED_APPS:
INSTALLED_APPS = [
...
'codemirror_editor',
]
Quick Start
In a Model
from django.db import models
from codemirror_editor.fields import CodeMirrorField
class Snippet(models.Model):
code = CodeMirrorField(language='javascript')
In a Form
from django import forms
from codemirror_editor.widgets import CodeMirrorWidget
class SnippetForm(forms.Form):
code = forms.CharField(widget=CodeMirrorWidget(language='html'))
In Django Admin
from django.contrib import admin
from codemirror_editor.widgets import AdminCodeMirrorWidget
class SnippetAdmin(admin.ModelAdmin):
formfield_overrides = {
models.TextField: {'widget': AdminCodeMirrorWidget(language='css')},
}
Configuration
The language parameter accepts: 'html', 'css', or 'javascript'.
Disclaimer
This project is not affiliated with, endorsed by, or associated with CodeMirror or its maintainers. It is an independent, third-party Django integration that bundles the CodeMirror 6 editor library.
License
MIT License - see LICENSE for details.
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_codemirror_editor-0.1.0.tar.gz.
File metadata
- Download URL: django_codemirror_editor-0.1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fadb5881b6e61ff90d777078611d8818f6d6f4920c76311509f87c699c8e481
|
|
| MD5 |
032b71b45719fc5c5e0cdb77f81956d1
|
|
| BLAKE2b-256 |
9ba164fa767eb73c4565b5f26a72e19bc9bac760335e8b07a035db432e766a21
|
Provenance
The following attestation bundles were made for django_codemirror_editor-0.1.0.tar.gz:
Publisher:
publish.yml on arthanson/django-codemirror-editor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_codemirror_editor-0.1.0.tar.gz -
Subject digest:
1fadb5881b6e61ff90d777078611d8818f6d6f4920c76311509f87c699c8e481 - Sigstore transparency entry: 1229977141
- Sigstore integration time:
-
Permalink:
arthanson/django-codemirror-editor@11f640df4592a30ce6366d7e9a351817fa8e4403 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/arthanson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@11f640df4592a30ce6366d7e9a351817fa8e4403 -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_codemirror_editor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_codemirror_editor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 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 |
b46fc9d64fc0d2ecb3ee1cbe10a49fea5f234c15f7588d7aa04b09264f89f018
|
|
| MD5 |
c2ebecaea434278e045ab63f7c78408d
|
|
| BLAKE2b-256 |
adafddf98dce3435cc7e386a6074ffb704ec315d9dff94ac56f1925d505a414a
|
Provenance
The following attestation bundles were made for django_codemirror_editor-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on arthanson/django-codemirror-editor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_codemirror_editor-0.1.0-py3-none-any.whl -
Subject digest:
b46fc9d64fc0d2ecb3ee1cbe10a49fea5f234c15f7588d7aa04b09264f89f018 - Sigstore transparency entry: 1229977151
- Sigstore integration time:
-
Permalink:
arthanson/django-codemirror-editor@11f640df4592a30ce6366d7e9a351817fa8e4403 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/arthanson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@11f640df4592a30ce6366d7e9a351817fa8e4403 -
Trigger Event:
release
-
Statement type: