1

I have an nbd model defined as such:

class Attachment(ndb.Model):

    id              = ndb.StringProperty(indexed=True)
    mime_type       = ndb.StringProperty()
    contents        = ndb.StringProperty()
    modified_date   = ndb.DateTimeProperty(auto_now_add=True)

    def __init__(self, *args, **kwargs):
        super(Attachment, self).__init__(*args, **kwargs)

As per documentation and coincidentally BDFL's direction, you can overwrite __init__ in a ndb.Model subclass by calling the above super(); however, every time I'm trying to create a new instance as follows: Attachment(id='such',mime_type='img/jpeg') keeps throwing errors that those args are unexpected.

What am I missing? Your help is much appreciated.

4

1 回答 1

2

好吧,看来我搞砸了模型定义并且由于上帝的安排而工作。相关文件:

您不能轻易定义名为“key”、“id”、“parent”或“namespace”的属性。例如,如果您在构造函数或 populate() 调用中传递 key="foo",它会设置实体的键,而不是名为“key”的属性属性。

于 2013-08-26T15:03:58.627 回答