ubuntu下 Django 安装配置富文本编辑器

  1. 安装
    pip install django-tinymce==2.6.0
    使了几次都报这个错误:
    ERROR: Could not find a version that satisfies the requirement django-tinymc (from versions: none)
    ERROR: No matching distribution found for django-tinymc

本来都已经绝望了,结果最后居然成功了,不知道怎么回事。
Collecting django-tinymce==2.6.0
Downloading https://files.pythonhosted.org/packages/84/f0/a97379fd588227813ecf31036f3122f39515eec9a94069ac1265941c67ba/django_tinymce-2.6.0-py2.py3-none-any.whl (4.1MB)
|████████████████████████████████| 4.1MB 1.2MB/s
Installing collected packages: django-tinymce
Successfully installed django-tinymce-2.6.0

2.在setting中注册富文本编辑器信息
INSTALLED_APPS = [
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘tinymce’, # 富文本编辑器 这里这里
‘freshday’,
]
和这个:
TINYMCE_DEFAULT_CONFIG = {
‘theme’: ‘advanced’,
‘width’: 600,
‘height’: 400,
}

3.在urls.py中配置 url(r’^tinymce/’, include(‘tinymce.urls’)),

4.在model.py 添加

from django.db import models
from tinymce.models import HTMLField
 content = HTMLField(‘正文’)

你可能感兴趣的:(Django)