I have a model in Django 1.2.4:
class MyModel():
foo = IntegerField(verbose_name="bar")
def printFoo(self):
print("Value of %s is %d" % (foo.verbose_name, foo))
I'm trying to get both the valu开发者_StackOverflow社区e and verbose name of a field. How can I do this?
I've looked at myModel._meta.fields
, but I'm not sure if that's the way to go.
Probably like this:
MyModel._meta.get_field('foo').verbose_name
See How can I programmatically obtain the max_length of a Django model field? for a very similar question.
精彩评论