天天看点

django之BBS需求分析和orm设计-71一.BBS博客需求分析

django之BBS需求分析和orm设计-71

一.BBS博客需求分析

首页(现实文章)
文章详情
点赞
文章评论(子评论,评论的展示)
登录功能(图片验证码)
注册功能(基于form验证)
个人站点(不同人不同样式,文章过滤)
后台管理(文章展示)
新增文章(富文本编辑器)
           

二.ORM模型设计

需要创建的表

用户信息表-----UserInfo
个人站点表-----Blog
分类表--------Category
标签表--------Tag
文章表--------Article 文章与标签的关联表---ArticleToTag 点赞点踩表-----UpAndDown 文章评论表-----Commit
           

表与表之间的关联关系

UserInfo --- 一对一 ---Blog
Blog --- 一对多 --- Category Blog --- 一对多 --- Tag Article --- 一对多 --- UserInfo Article --- 一对多 --- Category Article --- 多对多 --- Tag UpAndDown --- 一对多 --- UserInfo UpAndDown --- 一对多 --- Article Commit --- 一对多 --- UserInfo Commit --- 一对多 --- Article 子评论关联Commit自身
           

三.配置文件

配置需要使用的数据库

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'day86_BBS', 'PORT':                 

扩展默认的auth_user表的配置

根路由配置

静态文件配置

STATICFILES_DIRS = [
    os.path.join(BASE_DIR,'static')
]                

四.创建表模型

from django.db import models
from django.contrib.auth.models import AbstractUser # Create your models here. class Blog(models.Model): ''' 个人站点表 ''' id = models.AutoField(primary_key=True) title = models.CharField(max_length=                

五.生成5位随机验证码

from django.shortcuts import render, HttpResponse
from PIL import Image, ImageDraw, ImageFont import random from io import BytesIO # 生成随机颜色 def get_color(): return ( random.randint(                

posted on 2018-12-27 21:47 漫天飞雪世情难却 阅读( ...) 评论( ...)   编辑 收藏

转载于:https://www.cnblogs.com/jokezl/articles/10187625.html