views:

71

answers:

2

Given a model like so:

 from google.appengine.ext import db
 class X(db.Model):
    p = db.StringProperty(verbose_name="Like π, but more modern.")

How does one access verbose_name from x=X() (an instance of X)?

One might expect that x.p.verbose_name would work, or alternatively x.properties()['p'].verbose_name, but neither seems to work.

Thanks!

EDIT: x.name.verbose_name => x.p.verbose_name

A: 
x = X(p="Foo!")
print x.p.verbose_name

Does that work?

Jason Hall
Alas, no. (Fixed typo in the example). Note that I'm trying to access `x.p.verbose_name` in Jinja2, if that makes any difference.
Brian M. Hunt
+2  A: 

x.properties()['p'].verbose_name definitely works - you can verify for yourself on http://shell.appspot.com/

Nick Johnson
Okay, thank you. Strange - it just didn't seem to work when I was trying it. Must've been a bug in my code! At least I had the right idea. Thanks! :)
Brian M. Hunt