我们从Python开源项目中,提取了以下20个代码示例,用于说明如何使用wtforms.fields.attname()。
def model_fields(model, only=None, exclude=None, field_args=None, converter=None): """ Generate a dictionary of fields for a given Django model. See `model_form` docstring for description of parameters. """ converter = converter or ModelConverter() field_args = field_args or {} model_fields = ((f.attname, f) for f in model._meta.fields) if only: model_fields = (x for x in model_fields if x[0] in only) elif exclude: model_fields = (x for x in model_fields if x[0] not in exclude) field_dict = {} for name, model_field in model_fields: field = converter.convert(model, model_field, field_args.get(name)) if field is not None: field_dict[name] = field return field_dict