删除用户后,我的模型Tasks
包含user
外键,删除创建者后如何将另一个用户作为备份用户添加到该对象?
first_user = User.objects.get(username='nagah')
class Task(models.Model):
taskname = models.CharField(max_length=30)
created = models.DateTimeField(auto_now=True)
is_complete = models.BooleanField(default=False)
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, default=first_user.id)