'Validate that readonly_fields refers to proper attribute or field.'

def validate_readonly_fields(self, cls, model):

    if hasattr(cls, 'readonly_fields'):
        check_isseq(cls, 'readonly_fields', cls.readonly_fields)
        for (idx, field) in enumerate(cls.readonly_fields):
            if (not callable(field)):
                if (not hasattr(cls, field)):
                    if (not hasattr(model, field)):
                        try:
                            model._meta.get_field(field)
                        except models.FieldDoesNotExist:
                            raise ImproperlyConfigured(('%s.readonly_fields[%d],    %r    is    not    a    callable    or    an    attribute    of    %r    or    found    in    the    model    %r.' % (cls.__name__, idx, field, cls.__name__, model._meta.object_name)))
