'Validate that raw_id_fields only contains field names that are listed on the model.'

def validate_raw_id_fields(self, cls, model):

    if hasattr(cls, 'raw_id_fields'):
        check_isseq(cls, 'raw_id_fields', cls.raw_id_fields)
        for (idx, field) in enumerate(cls.raw_id_fields):
            f = get_field(cls, model, 'raw_id_fields', field)
            if (not isinstance(f, (models.ForeignKey, models.ManyToManyField))):
                raise ImproperlyConfigured(("'%s.raw_id_fields[%d]',    '%s'    must    be    either    a    ForeignKey    or    ManyToManyField." % (cls.__name__, idx, field)))
