zoukankan      html  css  js  c++  java
  • djang系列5.5-- 图书管理系统实例

    一.表格设计

    E-R图

    分析图

     

    models.py

    from django.db import models
    
    # Create your models here.
    
    
    class Author(models.Model):
    
        id = models.AutoField(primary_key=True)
        name = models.CharField(max_length=32)
        age = models.IntegerField()
        au = models.OneToOneField(to='AuthorDetail',to_field='id',on_delete=models.CASCADE)
    
    
    class AuthorDetail(models.Model):
    
        id = models.AutoField(primary_key=True)
        address = models.CharField(max_length=32)
        tel = models.CharField(max_length=11)
    
    
    class Publish(models.Model):
    
        id = models.AutoField(primary_key=True)
        name = models.CharField(max_length=22)
        addr = models.CharField(max_length=64)
    
    
    class Book(models.Model):
    
        id = models.AutoField(primary_key=True)
        title = models.CharField(max_length=32)
        price = models.DecimalField(max_digits=5, decimal_places=2)
        publisher = models.ForeignKey(to='Publish',to_field='id',on_delete=models.CASCADE)
        authors = models.ManyToManyField(to='Author')
  • 相关阅读:
    BETA 版冲刺前准备
    alpha事后诸葛亮
    alpha冲刺10
    alpha冲刺9
    alpha冲刺8
    alpha冲刺7
    alpha冲刺6
    alpha冲刺5
    第十一次作业
    Alpha冲刺一 (10/10)
  • 原文地址:https://www.cnblogs.com/robertx/p/10467347.html
Copyright © 2011-2022 走看看