在admin或者adminx后臺中使用富文本編輯器 一.建立模型:(安裝django-tinymce==2.6.0) from django.db import models from tinymce.models import HTMLField # Create your models here. class GoodTest(models.Model): status_choices = ( (0, '下線'), (1, '上線') ) status = models.SmallIntegerField(default=1, choices=status_choices, verbose_name='狀態(tài)') # 富文本類型:帶有格式的文本python基礎(chǔ)教程商品詳情') 二.在settings.py中完成配置 INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'app01.apps.App01Config', 'tinymce', ] TINYMCE_DEFAULT_CONFIG = { 'theme': 'advanced', 'width': 600, 'height': 400, } 三.路由分發(fā) url('tinymce/', include('tinymce.urls')), # 富文本編輯器 四. admin.py中完成注冊 from app01.models import GoodTest # Register your models here. admin.site.register(GoodTest) |
|