예제 #1
0
    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)
예제 #2
0
class EditProfileForm(forms.EditProfileForm):
    activated = fields.BooleanField('Activated')
    #group = fields.SelectField()_('Country'), choices=[])
    group = KeyPropertyField('Group', reference_class=Group)
예제 #3
0
 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)
예제 #4
0
파일: test_ndb.py 프로젝트: quantus/wtforms
 class F(Form):
     author = KeyPropertyField(reference_class=Author)