【发布时间】:2012-01-22 13:16:21
【问题描述】:
这里有一些模型:
class UserProfile(models.Model):
name = models.CharField(max_length=30)
email = models.EmailField(unique=True, db_index=True)
birthday = models.DateField()
class Photo(models.Model):
user = models.ForeignKey(UserProfile)
description = models.TextField(blank=True)
photo = models.ImageField(upload_to='img/photo')
假设用户有 10 张照片(Photo 模型的 10 个对象)。当用户删除自己时,所有这 10 个Photo 数据库行会自动删除自己吗? (我读过文档,但英语不是我的母语,所以我对on_delete 属性一无所知。)
【问题讨论】:
标签: django django-models