def get_field_attr(model, field_name, attr):
    try:
        field_data = model._meta.get_field_by_name(field_name)
    except FieldDoesNotExist:
        return ''
    else:
        field, model, direct, m2m = field_data
        return getattr(field, attr, '')
Return the specified field for a model field
dataset/ETHPy150Open dropbox/nsot/nsot/util/core.py/get_field_attr