如何将WMD编辑器连接到我的django表单上?
这是完整的Django小部件类:
class WMDEditor(forms.Textarea): def __init__(self, *args, **kwargs): attrs = kwargs.setdefault('attrs', {}) if 'cols' not in attrs: attrs['cols'] = 58 if 'rows' not in attrs: attrs['rows'] = 8 super(WMDEditor, self).__init__(*args, **kwargs) def render(self, name, value, attrs=None): rendered = super(WMDEditor, self).render(name, value, attrs) return rendered + mark_safe(u''' ''' % settings.MEDIA_URL)
在表单定义中使用它text = forms.CharField(widget=WMDEditor)
.