在Admin中使用
- 在booktest/models.py中,定义模型的属性为HTMLField()类型
from django.db import models
from tinymce.models import HTMLField
class GoodsInfo(models.Model):
gcontent=HTMLField()
python manage.py makemigrations

python manage.py migrate
- 在本示例中没有定义其它的模型类,但是数据库中有这些表,提示是否删除,输入no后回车,表示不删除,因为其它的示例中需要使用这些表

- 迁移完成,新开终端,连接mysql,使用test2数据库,查看表如下

- 发现并没有表GoodsInfo,解决办法是删除迁移表中关于booktest应用的数据
delete from django_migrations where app='booktest';
python manage.py migrate

- 在booktest/admin.py中注册模型类GoodsInfo
from django.contrib import admin
from models import *
class GoodsInfoAdmin(admin.ModelAdmin):
list_display = ['id']
admin.site.register(GoodsInfo,GoodsInfoAdmin)
- 运行服务器,进入admin后台管理,点击GoodsInfo的添加,效果如下图
