'Overrides the default widget for Foreignkey fields if they are
specified in the related_search_fields class attribute.'

def formfield_for_dbfield(self, db_field, **kwargs):

    if (isinstance(db_field, models.ForeignKey) and (db_field.name in self.related_search_fields)):
        model_name = db_field.rel.to._meta.object_name
        help_text = self.get_help_text(db_field.name, model_name)
        if kwargs.get('help_text'):
            help_text = six.u(('%s    %s' % (kwargs['help_text'], help_text)))
        kwargs['widget'] = ForeignKeySearchInput(db_field.rel, self.related_search_fields[db_field.name])
        kwargs['help_text'] = help_text
    return super(ForeignKeyAutocompleteAdmin, self).formfield_for_dbfield(db_field, **kwargs)
