是否可以为模型设置默认值?例如,从Appengine Documentation中考虑此模型
from google.appengine.ext import db class Pet(db.Model): name = db.StringProperty(required=True) type = db.StringProperty(required=True,choices=set(["cat","dog","bird"])) birthdate = db.DateProperty() weight_in_pounds = db.IntegerProperty() spayed_or_neutered = db.BooleanProperty() owner = db.UserProperty(required=True)
我想将name的默认值设置为“Unnamed Pet”,因此如果用户不提供,则采用默认值.这可能吗?
PS:我希望这可以在模型类Pet本身中完成