dir() was not overrideable on python2.5 so it doesn't trigger an import of the real settings module. Use getattr() instead, this works accross all versions.