【发布时间】:2020-05-26 23:16:38
【问题描述】:
我正在一个 Django 项目中编写测试,并且设置了一些工厂来创建测试内容。我现在遇到了一些问题,电子邮件地址没有保存到数据库中:
device = DeviceFactory.create()
device.owner.email = 'a@b.c'
device.save()
print(device.owner.email) # prints out 'a@b.c'
print(device.id) # prints out 1
d = Device.objects.get(id=device.id) # get the object from the DB again
print(d.owner.email) # prints out jon.avery@ourcompany.com (or any other mock email address the factory creates)
为什么不将记录保存到数据库中?
【问题讨论】:
标签: python django django-models orm model