Django-mdeditor is Markdown Editor plugin application for django base on
Clone or download
Latest commit 303c953 Jan 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
mdeditor 修改 静态文件路径 Jan 16, 2019
mdeditor_demo 补充mdeditor需要的js库 Sep 18, 2018
mdeditor_demo_app 修改 静态文件路径 Jan 16, 2019
screenshot init commit Mar 5, 2018
uploads init commit Mar 5, 2018
.gitattributes 更新语言属性 Mar 7, 2018
.gitignore 补充mdeditor需要的js库 Sep 18, 2018
LICENSE Initial commit Mar 2, 2018 init commit Mar 5, 2018
Pipfile 修改版本号 Oct 30, 2018
Pipfile.lock 修改版本号 Oct 30, 2018 需改版本号 Jan 16, 2019 需改版本号 Jan 16, 2019
db.sqlite3 修改版本号 Oct 30, 2018
django_and_editor.png add png Mar 5, 2018 init commit Mar 5, 2018 需改版本号 Jan 16, 2019



Django-mdeditor is Markdown Editor plugin application for django base on

Django-mdeditor was inspired by great django-ckeditor.

Note: For Markdown page rendering issues, backend rendering is recommended. Because has not been updated for a long time, some bugs and compatibility issues need to be debugged. Of course, front-end students can choose.


  • Almost features
    • Support Standard Markdown / CommonMark and GFM (GitHub Flavored Markdown);
    • Full-featured: Real-time Preview, Image (cross-domain) upload, Preformatted text/Code blocks/Tables insert, Search replace, Themes, Multi-languages;
    • Markdown Extras : Support ToC (Table of Contents), Emoji;
    • Support TeX (LaTeX expressions, Based on KaTeX), Flowchart and Sequence Diagram of Markdown extended syntax;
  • Can constom toolbar
  • The MDTextField field is provided for the model and can be displayed directly in the django admin.
  • The MDTextFormField is provided for the Form and ModelForm.
  • The MDEditorWidget is provided for the Admin custom widget.

Quick start

  • Installation.
    pipenv install django-mdeditor
    # or
    pip install django-mdeditor
  • Add mdeditor to your INSTALLED_APPS setting like this:
  • Add 'media' url to your settings like this:
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
MEDIA_URL = '/media/'

Make folder uploads/editor in you project for media files.

  • Add url to your urls like this:
from django.conf.urls import url, include
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
    url(r'mdeditor/', include('mdeditor.urls'))

if settings.DEBUG:
    # static files (images, css, javascript, etc.)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  • Write your models like this:
from django.db import models
from mdeditor.fields import MDTextField

class ExampleModel(models.Model):
    name = models.CharField(max_length=10)
    content = MDTextField()
  • Register your model in

  • Run python makemigrations and python migrate to create your models.

  • Login Admin ,you can see a markdown editor text field like this:


Edit fields in the model using Markdown

Using Markdown to edit the fields in the model, we simply replace the TextField of the model with MDTextField.

from django.db import models
from mdeditor.fields import MDTextField

class ExampleModel (models.Model):
    name = models.CharField (max_length = 10)
    content = MDTextField ()

Admin in the background, will automatically display markdown edit rich text.

Used in front-end template, you can use like this:

{% load staticfiles%}
<! DOCTYPE html>
<html lang = "en">
        <meta http-equiv = "Content-Type" content = "text / html; charset = utf-8" />

    </ head>
        <form method = "post" action = "./">
            {% csrf_token%}
            <p> <input type = "submit" value = "post"> </ p>
        </ form>
    </ body>
</ html>

Edit fields in the Form using markdown

Use markdown to edit fields in the Form, use MDTextFormField instead of forms.CharField, as follows:

from mdeditor.fields import MDTextFormField

class MDEditorForm (forms.Form):
    name = forms.CharField ()
    content = MDTextFormField ()

ModelForm can automatically convert the corresponding model field to the form field, which can be used normally:

class MDEditorModleForm (forms.ModelForm):

    class Meta:
        model = ExampleModel
        fields = '__all__'

Use the markdown widget in admin

Use the markdown widget in admin like as :

from django.contrib import admin
from django.db import models

# Register your models here.
from. import models as demo_models
from mdeditor.widgets import MDEditorWidget

class ExampleModelAdmin (admin.ModelAdmin):
    formfield_overrides = {
        models.TextField: {'widget': MDEditorWidget}
    } (demo_models.ExampleModel, ExampleModelAdmin)

Customize the toolbar

Add the following configuration to settings:

        'width': '90% ',  # Custom edit box width
        'heigth': 500,  # Custom edit box height
        'toolbar': ["undo", "redo", "|",
                    "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|",
                    "h1", "h2", "h3", "h5", "h6", "|",
                    "list-ul", "list-ol", "hr", "|",
                    "link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime"
                    "emoji", "html-entities", "pagebreak", "goto-line", "|",
                    "help", "info",
                    "||", "preview", "watch", "fullscreen"],  # custom edit box toolbar 
        'upload_image_formats': ["jpg", "jpeg", "gif", "png", "bmp", "webp"],  # image upload format type
        'image_floder': 'editor',  # image save the folder name
        'theme': 'default',  # edit box theme, dark / default
        'preview_theme': 'default',  # Preview area theme, dark / default
        'editor_theme': 'default',  # edit area theme, pastel-on-dark / default
        'toolbar_autofixed': True,  # Whether the toolbar capitals
        'search_replace': True,  # Whether to open the search for replacement
        'emoji': True,  # whether to open the expression function
        'tex': True,  # whether to open the tex chart function
        'flow_chart': True,  # whether to open the flow chart function
        'sequence': True  # Whether to open the sequence diagram function


[issue] Welcome to use and feedback!