def model_form(model, db_session=None, base_class=Form, only=None,
    exclude=None, field_args=None, converter=None, exclude_pk=True,
    exclude_fk=True, type_name=None):
    if not hasattr(model, '_sa_class_manager'):
        raise TypeError('model must be a sqlalchemy mapped model')

    if not exclude:
        exclude = []
    model_mapper = model.__mapper__
    for prop in model_mapper.iterate_properties:
        if not hasattr(prop, 'direction') and prop.columns[0].primary_key:
            if exclude_pk:
                exclude.append(prop.key)
        if hasattr(prop, 'direction') and exclude_fk and \
                prop.direction.name != 'MANYTOMANY':
            for pair in prop.local_remote_pairs:
                exclude.append(pair[0].key)
    type_name = type_name or str(model.__name__ + 'Form')
    field_dict = model_fields(model, db_session, only, exclude, field_args, converter)
    return type(type_name, (base_class, ), field_dict)
if order is asc, queryset should be sorted ascending.
dataset/ETHPy150Open RoseOu/flasky/venv/lib/python2.7/site-packages/wtforms/ext/sqlalchemy/orm.py/model_form--crossover with--dataset/ETHPy150Open ofa/connect/open_connect/media/tests/test_views.py/URLPopularityViewTest.test_order_is_asc