def fetch_attr(cls, model, opts, label, field):
    try:
        return opts.get_field(field)
    except models.FieldDoesNotExist:
        pass
    try:
        return getattr(model, field)
    except __HOLE__:
        raise ImproperlyConfigured("'%s.%s' refers to '%s' that is neither a field, method or property of model '%s'."
            % (cls.__name__, label, field, model.__name__))
dataset/ETHPy150Open dcramer/django-compositepks/django/contrib/admin/validation.py/fetch_attr