views:

65

answers:

1

Google App Engine models, likeso:

from google.appengine.ext.db import Model

class M(Model):
    name = db.StringProperty()

Then in a Jinja2 template called from a Django view with an in instance of M passed in as m:

The name of this M is {{ m.name }}.

When m is initialized without name being set, the following is printed:

The name of this M is None.

The preferable and expected output (and the output when using Django templates) would be/is:

The name of this M is .

Do you know why this is happening, and how to get the preferred & expected output?

+2  A: 

I think you hit upon the answer yourself. If you don't specify a name for that property, App Engine appears to store it as None, not "", so when it's printed, it gets printed as "None". Specify the default as "" and your problem goes away, like you said.

Jason Hall
It's noteworthy that you may be able to remedy this problem by tinkering with `class jinja2.Undefined` too.
Brian M. Hunt