Handle AttributeError in db.utils _route_db for Django ticket #21755.