我是GAE和Python的新手,我正在学习谷歌提供的教程,但是当我尝试在同一文件中创建多个模型类时,问题就来了。如果我添加这样的内容:
class Greeting(ndb.Model):
"""Models an individual Guestbook entry with author, content, and date."""
author = ndb.UserProperty()
content = ndb.StringProperty(indexed=False)
email = ndb.StringProperty()
date = ndb.DateTimeProperty(auto_now_add=True)
colours = ndb.StringProperty(repeated=True)
class UserInformation(ndb.model):
username = ndb.UserProperty()
firstname = ndb.StringProperty(required=True)
lastname = ndb.StringProperty(required=True)
telephone = ndb.IntegerProperty()
我得到以下错误信息
Traceback (most recent call last):
File "C:Program Files (x86)Googlegoogle_appenginegoogleappengineruntimewsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:Program Files (x86)Googlegoogle_appenginegoogleappengineruntimewsgi.py", line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:Program Files (x86)Googlegoogle_appenginegoogleappengineruntimewsgi.py", line 84, in LoadObject
obj = __import__(path[0])
File "C:Python27gaelistpropertymain.py", line 37, in <module>
class UserInformation(ndb.model):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
如果我将UserInformation类放入第二个文件并尝试将其导入到main.py中,我将再次得到类似的错误消息。
我的问题是什么是最好的方式来处理多个ndb。模型类在GAE使用Python?
如有任何帮助,不胜感激
你打错了,换行:
class UserInformation(ndb.model):
to(注意大写的M
):
class UserInformation(ndb.Model):