Skip to main content

Django form widget library for using CodeMirror on textarea

Project description

Version Status License Python versions

This Package is wrapper of django-codemirror-widget

Django form widget library for using CodeMirror on Textarea.

Installation

pip install django-codemirror-widget-2

Usage

  1. First, you need to specified CODEMIRROR_PATH on settings.py. 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(
        mode="python",
        theme="cobalt",
        config={
            'fixedGutter': True
        },
    )
    document = forms.TextField(widget=codemirror_widget)

Settings

Use the followings in your settings.py.

CODEMIRROR_PATH

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

CODEMIRROR_MODE

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

CODEMIRROR_THEME

The default theme applied (DEFAULT: 'default')

CODEMIRROR_CONFIG

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

CODEMIRROR_JS_VAR_FORMAT

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)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

django_codemirror_widget_2-0.0.2-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file django_codemirror_widget_2-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: django_codemirror_widget_2-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

File hashes

Hashes for django_codemirror_widget_2-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 60d37fc5178995838826b8838ced75aa05ae325e7af2d11a30160dd7cc724640
MD5 9048223d952c4240ccc2ffd986d40160
BLAKE2b-256 b6accdb381068bd8b128ce99f30511947656602c4c041dc09a169af508c87029

See more details on using hashes here.

Supported by

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