企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] >[success] # 表的设计 ~~~ 文章: - id - 标题 - 作者 - 分类(多对一) - 标签(多对多) - 摘要 - 正文 - 状态 - 发布时间 分类: - id - 名称 - 状态 - 作者 - 创建时间 - 是否置顶导航 标签: - id - 名称 - 状态 - 作者 - 创建时间 友链: - id - 网站名称 - 链接 - 作者 - 状态 - 创建时间 - 权重 评论: - id - 文章(多对一) - 用户名 - 邮箱 - 网站地址 - 内容 - 创建时间 - 作者 侧栏: - id - 标题 - 类型(最新文章/最热文章/最近评论/内容) - 内容 - 创建时间 - 作者 ~~~ >[success] # 程序的目录 ~~~ . ├── CHANGELOG.md ├── LICENSE ├── README.md ├── requirements.txt └── typeidea ├── blog │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py ├── config │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py ├── comment │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py ├── manage.py └── typeidea ├── __init__.py ├── settings │ ├── __init__.py │ ├── base.py │ └── develop.py ├── urls.py └── wsgi.py ~~~ >[danger] ##### 博客--blong `from django.contrib.auth.models import User` 这个是其他人贡献的一个user库 表名`auth_user` ~~~ from django.db import models from django.contrib.auth.models import User # Create your models here. class Post(models.Model): STATUS_ITEMS = ( (1, "正常"), (2, "删除"), (3, "草稿"), ) title = models.CharField(max_length=225, verbose_name="标题") desc = models.CharField(max_length=1024, blank=True, verbose_name="摘要") content = models.TextField(verbose_name="正文", help_text="正文必须为MarkDown格式") status = models.PositiveIntegerField(default=1, choices=STATUS_ITEMS, verbose_name="状态") category = models.ForeignKey('Categroy', verbose_name="分类") tag = models.ManyToManyField('Tag', verbose_name="标签") owner = models.ForeignKey(User, verbose_name="作者") created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") class Meta: verbose_name = "文章" verbose_name_plural = "文章" class Categroy(models.Model): STATUS_ITMES = ( (1, "正常"), (2, "删除"), ) name = models.CharField(max_length=50, verbose_name="名称") status = models.PositiveIntegerField(default=1, choices=STATUS_ITMES, verbose_name="状态") is_nav = models.BooleanField(default=False, verbose_name="是否为导航") owner = models.ForeignKey(User, verbose_name="作者") created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") class Meta: verbose_name = verbose_name_plural = '分类' class Tag(models.Model): STATUS_ITEMS = ( (1, '正常'), (2, '删除'), ) name = models.CharField(max_length=10, verbose_name="名称") status = models.PositiveIntegerField(default=1, choices=STATUS_ITEMS, verbose_name="状态") owner = models.ForeignKey(User, verbose_name="作者") created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") class Meta: verbose_name = verbose_name_plural = '标签' ~~~ >[danger] ##### 评论 -- comment ~~~ from django.db import models from django.contrib.auth.models import User from blong.models import Post # Create your models here. class Comment(models.Model): STATUS_ITMES = ( (1,"正常"), (2,'删除') ) status = models.PositiveIntegerField(default=1, choices=STATUS_ITMES, verbose_name="状态") target = models.CharField(max_length=200, verbose_name="评论链接") content = models.CharField(max_length=2000, verbose_name="内容") nickname = models.CharField(max_length=10, verbose_name="昵称") website = models.URLField(verbose_name="网站") email = models.EmailField(verbose_name="邮箱") created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") class Meta: verbose_name_plural="评论" verbose_name="评论" ~~~ >[danger] ##### 侧边栏和友链 -- config ~~~ from django.db import models from django.contrib.auth.models import User # Create your models here. class Link(models.Model): STATUS_ITMES = ( (1,"正常"), (2,"删除"), ) # 加一句话 status = models.PositiveIntegerField(default=1, choices=STATUS_ITEMS, verbose_name="状态") title = models.CharField(max_length=50, verbose_name="标签") href = models.URLField(verbose_name="连接") status = models.PositiveIntegerField(default=1, choices=STATUS_ITMES, verbose_name="状态") weight = models.PositiveIntegerField(default=1, choices=zip(range(1, 6), range(1, 6)), verbose_name="权重", help_text="权重越高展示顺序约靠前") owner = models.ForeignKey(User, verbose_name="作者") created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") class Meta: verbose_name = verbose_name_plural = "友链" class SideBar(models.Model): STATUS_ITEMS = ( (1, '展示'), (2, '下线'), ) SIDE_TYPE = ( (1, 'HTML'), (2, '最新文章'), (3, '最热文章'), (4, '最近评论'), ) status = models.PositiveIntegerField(default=1, choices=STATUS_ITEMS, verbose_name="状态") title = models.CharField(max_length=50, verbose_name="标题") display_type = models.PositiveIntegerField(default=1, choices=SIDE_TYPE, verbose_name="展示类型") content = models.CharField(max_length=500, blank=True, verbose_name="内容", help_text="如果设置的不是HTML类型,可为空") owner = models.ForeignKey(User, verbose_name="作者") created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") class Meta: verbose_name = verbose_name_plural = "侧边栏" ~~~