Django WMD is a reusable Django application for a Markdown WMD editor. It consists of a widget, to be used on a
Django WMD uses ChiperSoft's WMD, which is a fork of Open Library's WMD, which is a fork of Stackoverflow's WMD, which was reverse-engineered from the original WMD by John Fraser (who was abducted by aliens sometime in 2008). It's sort of an orgy of forking.
- Put the
wmddirectory somewhere inside your Python path (like in your Django project folder).
To add the WMD widget to a field in the Django admin, first create a
ModelForm. Your application's
forms.py is probably a good place to put it. In this example, I'll assign the widget to the
body field of
from django import forms from myapp.models import Post from wmd.widgets import WMDWidget class PostForm(forms.ModelForm): body = forms.CharField(widget=WMDWidget) class Meta: model = Post
Then tell Django to use the
ModelForm on the admin site.
... from myapp.forms import PostForm class PostAdmin(admin.ModelAdmin): form = PostForm ... admin.site.register(Post, PostAdmin)
The widget currently takes one option:
large. If set to true, this will make the widgetized textarea larger than usual. This is much nicer for writing lengthy content, such as blog posts.
class PostForm(forms.ModelForm): body = forms.CharField(widget=WMDWidget(large=True) ...