Question

I am new to GAE and Python and I am working through the tutorials google provide, however the problem comes when I try and create more than 1 model class in the same file. If I add something like this:

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()

I get the following error message

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)

If I put the UserInformation class into a second file and try and import it into main.py I get a similar error message again.

My question is what is the best way to handle multiple ndb.model class in GAE using Python?

Any help would be appreciated

Was it helpful?

Solution

You have a typo, change the line:

class UserInformation(ndb.model):

to (notice the capital M):

class UserInformation(ndb.Model):

and it should work fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top