1.models.py
from django.db import models # Create your models here. class Class(models.Model): id = models.AutoField(primary_key=True) # 主键 cname = models.CharField(max_length=32) # 班级名称 first_day = models.DateField() # 开班时间 class Student(models.Model): id = models.AutoField(primary_key=True) sname = models.CharField(max_length=32) cid = models.ForeignKey("Class") detail = models.OneToOneField(to="StudentInfo", null=True) class StudentInfo(models.Model): height = models.CharField(max_length=4) weight = models.CharField(max_length=4) addr = models.CharField(max_length=32,null=True) class Teacher(models.Model): tname = models.CharField(max_length=32) # cid = models.ManyToManyField(to="Class", related_name="teachers") cid = models.ManyToManyField(to="Class")