【七侠传】冲刺阶段——Day1

【七侠传】冲刺阶段——Day1

团队成员

20181221曾宇涛 20181202李祎铭 20181209沙桐 20181215薛胜瀚 20181216杨越麒 20181223何家豪 20181232冶廷瑞


时间:11月23日

本日任务:后端开发

达成进度:

  • 完成了数据库与对象的ORM
  • 实现了模板应用实例化
  • 精简优化了数据库结构
  • 详细设计了重定向url方向
  • 完成了用户数据的相关内容

一、模型构建

from django.db import models

#用户类
class user(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=64)
    password = models.CharField(max_length=64)
    email = models.EmailField(max_length=100)
    # def __str__(self):
    #     return "<user object: {}{}{}{}>".format(self.id,self.name,self.password,self.email)

#文件类
class library(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=64)
    send_department = models.ForeignKey(to=user ,on_delete=models.deletion.CASCADE,related_name='library_acc_department')
    acc_department = models.ForeignKey(to=user,on_delete=models.deletion.CASCADE,related_name='library_send_department')
    path = models.CharField(max_length=100)
    pac_path = models.CharField(max_length=100)
    # def __str__(self):
    #     return "<library object: {}{}{}{}{}{}{}>".format(self.id,self.name,self.send_department,self.acc_department,self.path,self.pac_path,self.time)

数据库模型

setting.py中设置好数据库,并执行如下语句完成ORM(关系映射)

python manage.py makemigrations
python manage.py migrate

模型映射数据库完成,主键、外键、对应关系均可以使用

二、实例化应用

urls.py的代码片段

urls

views.py的代码片段

views

运行测试

用户登录页面

ceshi1

普通用户主页

ceshi2

管理员主页

ceshi3

三、小组合照

这是合照

四、明日计划


posted @ 2020-11-29 13:04  1202李祎铭  阅读(112)  评论(0编辑  收藏  举报