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)
class EditProfileForm(forms.EditProfileForm): activated = fields.BooleanField('Activated') #group = fields.SelectField()_('Country'), choices=[]) group = KeyPropertyField('Group', reference_class=Group)
def convert_KeyProperty(self, model, prop, kwargs): """Returns a form field for a ``ndb.KeyProperty``.""" kwargs['reference_class'] = prop._reference_class kwargs.setdefault('allow_blank', not prop._required) return KeyPropertyField(**kwargs)
class F(Form): author = KeyPropertyField(reference_class=Author)