BBS项目
BBS开发流程:
BBS项目:
开发流程:
需求分析
草拟一些项目的大致技术点和流程
架构设计
架构师(框架 语言 数据库 缓存数据库 表设计 拆分功能 项目的报价
分组开发
任务 按模块功能分的 组长在拆分功能 每个组员写几个小功能 需要提前测试一下有没有bug
交互测试
运维上线
BBS表格创建:
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class Userinfo(AbstractUser):
phone = models.BigIntegerField(null=True)
avatar = models.FileField(upload_to='avatar/',default='static/img/default.jpg')
# 该字段你直接传文件即可 会自动将文件保存到avatar文件夹下 然后数据库里面存文件路径
register_time = models.DateField(auto_now_add=True)
blog = models.OneToOneField(to='Blog',null=True)
class Blog(models.Model):
site_name = models.CharField(max_length=32)
site_tite = models.CharField(max_length=64)
site_theme = models.CharField(max_length=64)
# 该字段存的是用户自己写的css文件路径l
class Category(models.Model):
name = models.CharField(max_length=32)
blog = models.ForeignKey(to='Blog',null=True)
class Tag(models.Model):
name = models.CharField(max_length=32)
blog = models.ForeignKey(to='Blog',null=True)
class Article(models.Model):
title = models.CharField(max_length=64)
desc = models.CharField(max_length=255)
content = models.TextField()
create_time = models.DateField(auto_now_add=True)
# 数据库优化三个普通字段
up_num = models.IntegerField(default=0)
down_num = models.IntegerField(default=0)
comment_num = models.IntegerField(default=0)
# 外键字段
category = models.ForeignKey(to='Category',null=True)
blog = models.ForeignKey(to='Blog',null=True)
tags = models.ManyToManyField(to='Tag',through='Article2Tag',through_fields=('article','tags'))
class Article2Tag(models.Model):
article = models.ForeignKey(to='Article')
tags = models.ForeignKey(to='Tag')
class UpAndDown(models.Model):
user = models.ForeignKey(to='Userinfo')
article = models.ForeignKey(to='Article')
is_up = models.BooleanField()
class Comment(models.Model):
user = models.ForeignKey(to='Userinfo')
article = models.ForeignKey(to='Article')
content = models.CharField(max_length=255)
create_time = models.DateField(auto_now_add=True)
parent = models.ForeignKey(to='self',null=True) # 语义更明确
--》创建bbs 数据库 __init__ 导入:pymysql.install
--->settings内倒入 : AUTH_USER_MODEL = 'app.类名'
--》makemigrations
--》migrate