def remove_db_from_settings(dbname): """Remove that connection from settings.DATABASES and connections.databases.""" settings.DATABASES.pop(dbname, None) connections.databases.pop(dbname, None)