1

I have the following code in bulkloader.yaml:

  - property: dismissal_date
    external_name: dismissal_date
    import_transform: "lambda x: None if x is None or x=='' else datetime.datetime.strptime(x, '%d.%m.%Y').date()"

models.py:

class Employee(ndb.Model):
    dismissal_date = ndb.DateTimeProperty()

and upload file (csv):

last_name,first_name,middle_name,region,dismissal_date
Last name,First name,Middle name,22,13.01.2009

But I am getting the following error:

BadValueError: Unsupported type for property dismissal_date: <type 'datetime.date'>
4

1 回答 1

1

以下实际上有效(这很奇怪,因为文档说我应该使用.date()):

import_transform: "lambda x: None if x is None or x=='' else datetime.datetime.strptime(x, '%d.%m.%Y')"

transform.py 的来源有助于确定这一点。

我已将属性类型更改为DateProperty(),但仍使用时间组件 ( 00:00:00) 保存日期。

于 2012-07-24T18:44:47.020 回答