def model_fields(model, fields=None, readonly_fields=None, exclude=None,
                 field_args=None, converter=None):
    converter = converter or ModelConverter()
    field_args = field_args or {}

    model_fields = ((f.name, f) for f in model._meta.fields)
    if fields:
        model_fields = (x for x in model_fields if x[0] in fields)
    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
Generate a dictionary of fields for a given Django model.
dataset/ETHPy150Open syrusakbary/Flask-SuperAdmin/flask_superadmin/model/backends/django/orm.py/model_fields