DjangoUeditor https://github.com/zhangfisher/DjangoUeditor
1 DjangoUeditor 安装
pip install DjangoUeditor
需要修改的地方:
打开 %python_root%\Lib\site-packages\DjangoUeditor (如D:\Python\Python35\Lib\site-packages\DjangoUeditor)
commands.py:
from . import settings as USettings
forms.py
from .widgets import UEditorWidget
models.py
from DjangoUeditor.widgets import UEditorWidget, AdminUEditorWidget
settings.py
UserSettings=getattr(gSettings,"UEDITOR_SETTINGS",{}).copy()# if UserSettings.has_key("config"):UEditorSettings.update(UserSettings["config"])if UserSettings.get("config"):UEditorSettings.update(UserSettings["config"])# if UserSettings.has_key("upload"):UEditorUploadSettings.update(UserSettings["upload"])if UserSettings.get("upload"):UEditorUploadSettings.update(UserSettings["upload"])
# if UEditorSettings.has_key(key):if UEditorSettings.get(key):
urls.py
# from django.conf.urls import patterns, urlfrom django.conf.urls import url ###################
urlpatterns = [ url(r‘controller/$‘,get_ueditor_controller),]
views.py
全部的
except Exception,E: 改成
except Exception as E:
widgets.py
utils.py
使用方法参考
https://github.com/zhangfisher/DjangoUeditor
最后注意一点的事在 在模板里面 使用DjangoUeditor
<head>
......
{{ form.media }} #这一句会将DjangoUeditor 所需要的CSS和JS加进来。
......
</head>
最后再需要的元素中引用 form 如 <form> {{ form }} <form>
时间: 2024-10-24 23:33:11