The reason for this is that your for loop is running on both dbs, at first `allow_migrate()` returns `True` for the first db (`default`) thus setting `connection`, `allowed_len`, `db_alias` accordingly, but you are not terminating the loop, making it try `other` db with `allow_migrate()`, again returning `True` and setting the variables.