我是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)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 84, in LoadObject
obj = __import__(path[0])
File "C:\Python27\gae\listproperty\main.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,我会再次收到类似的错误消息。
我的问题是使用Python在GAE中处理多个ndb.model类的最佳方法是什么?
任何帮助将不胜感激
答案 0 :(得分:10)
你有一个错字,改变了一行:
class UserInformation(ndb.model):
to(注意大写M
):
class UserInformation(ndb.Model):
它应该可以正常工作。