EmailProperty
与StringProperty
的区别如何?考虑以下两个例子:
# example 1: store an e-mail address in an EmailProperty
class MyModel(db.Model):
email_address = db.EmailProperty()
m = MyModel()
m.email_address = db.Email("larry@example.com")
# example 2: store an e-mail address in a StringProperty
class MyModel(db.Model):
email_address = db.StringProperty()
m = MyModel()
m.email_address = "larry@example.com"
答案 0 :(得分:3)
如果您致电entity.to_xml()
,则电子邮件属性将在您实体的Atom表示中以gd:email的形式返回。
请注意,使用EmailProperty 不会自动验证电子邮件地址格式。