Skip to main content

Django form widget library for using CodeMirror on textarea

Project description

Version Status License Python versions

Django form widget library for using CodeMirror on Textarea.


pip install django-codemirror-widget


  1. First, you need to specified CODEMIRROR_PATH on CODEMIRROR_PATH is the URI of CodeMirror directory like CODEMIRROR_PATH = r"javascript/codemirror". If you don’t specify it, it defaults to 'codemirror'. CodeMirror should be put there.

  2. Use codemirror.CodeMirrorTextarea widget for target Textarea like below:

    from django import forms
    from codemirror import CodeMirrorTextarea
    codemirror_widget = CodeMirrorTextarea(
            'fixedGutter': True
    document = forms.TextField(widget=codemirror_widget)


Use the followings in your


The URI of CodeMirror directory (your CodeMirror installation should live in {{ STATIC_URL }}/{{ CODEMIRROR_PATH }})


The default mode which may be a string or configuration map (DEFAULT: 'javascript')


The default theme applied (DEFAULT: 'default')


Base mapping for the rest of the CodeMirror options (DEFAULT: { 'lineNumbers': True })


A format string interpolated with the form field name to name a global JS variable that will hold the CodeMirror editor object. For example with CODEMIRROR_JS_VAR_FORMAT = "%s_editor" and a field named ‘code’, the JS variable name would be ‘code_editor’. If CODEMIRROR_JS_VAR_FORMAT is None, no global variable is created (DEFAULT: None)

Download files

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

Files for django-codemirror-widget, version 0.5.0
Filename, size File type Python version Upload date Hashes
Filename, size django-codemirror-widget-0.5.0.tar.gz (6.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page