Skip to main content

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.

Download files

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

Source Distribution

django_codemirror_editor-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

django_codemirror_editor-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django_codemirror_editor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1fadb5881b6e61ff90d777078611d8818f6d6f4920c76311509f87c699c8e481
MD5 032b71b45719fc5c5e0cdb77f81956d1
BLAKE2b-256 9ba164fa767eb73c4565b5f26a72e19bc9bac760335e8b07a035db432e766a21

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on arthanson/django-codemirror-editor

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_codemirror_editor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_codemirror_editor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b46fc9d64fc0d2ecb3ee1cbe10a49fea5f234c15f7588d7aa04b09264f89f018
MD5 c2ebecaea434278e045ab63f7c78408d
BLAKE2b-256 adafddf98dce3435cc7e386a6074ffb704ec315d9dff94ac56f1925d505a414a

See more details on using hashes here.

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

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

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