📜  删除参数上的外键 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:14.414000             🧑  作者: Mango

代码示例1
class Artist(models.Model):
    name = models.CharField(max_length=10)

class Album(models.Model):
    artist = models.ForeignKey(Artist, on_delete=models.CASCADE)

class Song(models.Model):
    artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
    album = models.ForeignKey(Album, on_delete=models.RESTRICT)