一对多的概念 ,这里是一个出版社对应本书籍 ! 设计表使用model
models.ForeignKey(\'关联一\', on_delete=models.CASCADE) #给多设置外键 ,关联一 ,设置级联删除当一的内容被删除 ,所关联的多都被删除
from django.db import models # Create your models here. class presslist(models.Model): name = models.CharField(max_length=32) def __str__(self): return self.name class Book(models.Model): name = models.CharField(max_length=32) p_id = models.ForeignKey(\'presslist\', on_delete=models.CASCADE)