我有一个对用户有ForeignKey的模型:
class MyModel(models.Model):
key = models.CharField(max_length=40, primary_key=True)
user = models.ForeignKey(User)
当我尝试删除用户时,我得到例外:
IntegrityError: update or delete on table "users" violates foreign key constraint
在删除用户之前,我应该手动删除所有MyModel对象吗?我怎么能这样做?