django-markdownx
raw JSON → 4.0.9 verified Mon Apr 27 auth: no python
A comprehensive Markdown editor plugin for Django, providing a side-by-side live preview, image uploads with drag-and-drop, and custom markdown extensions. The latest version is 4.0.9. Release cadence is irregular.
pip install django-markdownx Common errors
error ModuleNotFoundError: No module named 'markdownx' ↓
cause Library not installed or not added to INSTALLED_APPS after installation.
fix
Run 'pip install django-markdownx' and add 'markdownx' to INSTALLED_APPS in settings.py.
error TypeError: __init__() missing 1 required positional argument: 'model_field' ↓
cause Using 'MarkdownxModelAdmin' incorrectly or custom admin not calling super with proper arguments.
fix
Ensure you register the model with 'MarkdownxModelAdmin' as shown: admin.site.register(ModelName, MarkdownxModelAdmin).
Warnings
breaking In v4.0.0, the model field class was renamed from 'MarkdownxField' to 'MarkdownxModelField'. Existing code using the old import will break. ↓
fix Replace 'from markdownx.models import MarkdownxField' with 'from markdownx.models import MarkdownxModelField'.
gotcha The 'MARKDOWNX_MARKDOWNIFY_FUNCTION' setting must be a string path to a callable, not a lambda or imported object, due to serialization requirements. ↓
fix Define a function in a separate module and reference it as 'mymodule.myfunc'.
Imports
- MarkdownxModelField wrong
from markdownx.models import MarkdownxFieldcorrectfrom markdownx.models import MarkdownxModelField
Quickstart
# 1. Add 'markdownx' to INSTALLED_APPS
# 2. In models.py:
from django.db import models
from markdownx.models import MarkdownxModelField
class MyModel(models.Model):
content = MarkdownxModelField()
# 3. In admin.py:
from django.contrib import admin
from markdownx.admin import MarkdownxModelAdmin
from .models import MyModel
admin.site.register(MyModel, MarkdownxModelAdmin)
# 4. Run migrations, then include markdownx URLs:
# path('markdownx/', include('markdownx.urls'))