Django form widget library for using CodeMirror on Textarea
sudo pip install django-codemirror-widget
or
sudo pip install git+git://github.com/lambdalisue/django-codemirror-widget.git#egg=django-code-mirror
First, you need to specified
CODEMIRROR_PATHonsettings.py.CODEMIRROR_PATHis the URI of CodeMirror directory likeCODEMIRROR_PATH = r"javascript/codemirror". If you don't specify it, it defaults to'codemirror'. CodeMirror should be put there.Use
codemirror.widgets.CodeMirrorTextareawidgets for target Textarea like below:from django import forms from codemirror.widgets import CodeMirrorTextarea codemirror = CodeMirrorTextarea(mode="python", theme="cobalt", config={ 'fixedGutter': True }) document = forms.TextField(widget=codemirror)
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 })