coto / gae-boilerplate

Google App Engine Boilerplate
https://dev-dot-sandengine.appspot.com/
Other
685 stars 189 forks source link

Type Error in Development Server When Logging in #298

Open gadgster opened 10 years ago

gadgster commented 10 years ago

Hello,

The first time I ran GAE Boilerplate, I clicked on login using your Google account and got a type error:

File "models.py", line 35, in <lambda> full_name = ndb.ComputedProperty(lambda self: self.name + " " + self.last_name) TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

I fixed this by changing line 35 in models.py to:

full_name = ndb.ComputedProperty(lambda self: "{} {}".format(self.name, self.last_name,))

I'm not sure if that's actually fixing the problem or just avoiding it.

Thanks Richard

andrewgreensmith commented 10 years ago

Hi, I'm guessing you don't actually have a "name" or "last_name" since you signed in with google. I sort of got round this in my application by having a display name too and never refer to full name directly since I always want to show something. @property def display_name(self): if self.name or self.last_name: return self.full_name else: return self.username

hope that helps, I should really get round to sticking some of my updates onto my fork :)

gadgster commented 10 years ago

I think changing line 35 of models.py to:

full_name = ndb.ComputedProperty(lambda self: "{} {}".format(self.name, self.last_name,))

Would fix this.