问题描述
在我的模型中,我有一个属性:
$ p $ created = db.DateTimeProperty(required = True,auto_now_add = True)
在数据存储中创建此类型的对象时,创建的属性自动填充。
当我使用没有此字段的表的批量加载器工具时,当我上传到AppEngine时,字段不会自动填充创建新的对象。
如何设置从批量加载器上传的新对象的创建时间?
在bulkloader.yaml中添加如下内容:
- property:created
external_name:created
import_transform:lambda x:datetime.datetime.utcnow()
In my model I have a property:
created = db.DateTimeProperty(required=True, auto_now_add=True)
When an object of this type is created in the datastore, the created property is automatically populated.
When I use the bulk loader tool with a table which does not have this field, the field is not automatically populated when I upload to AppEngine, at which time new objects are created.
How can I make it set the created time on new objects uploaded from the bulk loader?
Add something like the following to bulkloader.yaml:
- property: created
external_name: created
import_transform: "lambda x: datetime.datetime.utcnow()"
这篇关于AppEngine批量加载器和自动创建的属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!