本文整理匯總了Python中wtforms.ext.appengine.fields.KeyPropertyField方法的典型用法代碼示例。如果您正苦於以下問題:Python fields.KeyPropertyField方法的具體用法?Python fields.KeyPropertyField怎麽用?Python fields.KeyPropertyField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wtforms.ext.appengine.fields
的用法示例。
在下文中一共展示了fields.KeyPropertyField方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: convert_KeyProperty
# 需要導入模塊: from wtforms.ext.appengine import fields [as 別名]
# 或者: from wtforms.ext.appengine.fields import KeyPropertyField [as 別名]
def convert_KeyProperty(self, model, prop, kwargs):
"""Returns a form field for a ``ndb.KeyProperty``."""
if 'reference_class' not in kwargs:
try:
reference_class = prop._kind
except AttributeError:
reference_class = prop._reference_class
if isinstance(reference_class, string_types):
# reference class is a string, try to retrieve the model object.
mod = __import__(model.__module__, None, None, [reference_class], 0)
reference_class = getattr(mod, reference_class)
kwargs['reference_class'] = reference_class
kwargs.setdefault('allow_blank', not prop._required)
return KeyPropertyField(**kwargs)