如何在 Django 后台 admin 中集成一个富文本编辑器
展开全部
一、下载安装
python setup.py install
二、
1.将tinymce/static/tiny_mce文件夹放到your_project/static目录下;
2.将tinymce文件夹放到your_project目录下
三、在urls.py文件中加入:
url(r'^tinymce/',include('tinymce.urls')),
四、在settings.py文件中加入:
INSTALLED_APPS = (
'tinymce',
)
五、在settings.py文件中加入:
TINYMCE_JS_URL=MEDIA_URL+'/static/tiny_mce/tiny_mce_src.js'
TINYMCE_JS_ROOT=MEDIA_ROOT+'/static/tiny_mce/'
六、在settings.py文件中加入:
TINYMCE_DEFAULT_CONFIG = {
'theme': "advanced",
'theme_advanced_toolbar_location' : "top",
'theme_advanced_toolbar_align' : "left",
‘width’: 600,
‘height’: 400,
}
七、修改models.py文件
from your_project.tinymce import models as tinymce_models
class Post(models.Model):
body=tinymce_models.HTMLField()
python setup.py install
二、
1.将tinymce/static/tiny_mce文件夹放到your_project/static目录下;
2.将tinymce文件夹放到your_project目录下
三、在urls.py文件中加入:
url(r'^tinymce/',include('tinymce.urls')),
四、在settings.py文件中加入:
INSTALLED_APPS = (
'tinymce',
)
五、在settings.py文件中加入:
TINYMCE_JS_URL=MEDIA_URL+'/static/tiny_mce/tiny_mce_src.js'
TINYMCE_JS_ROOT=MEDIA_ROOT+'/static/tiny_mce/'
六、在settings.py文件中加入:
TINYMCE_DEFAULT_CONFIG = {
'theme': "advanced",
'theme_advanced_toolbar_location' : "top",
'theme_advanced_toolbar_align' : "left",
‘width’: 600,
‘height’: 400,
}
七、修改models.py文件
from your_project.tinymce import models as tinymce_models
class Post(models.Model):
body=tinymce_models.HTMLField()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询