Instead of relying on the index, which is a bit brittle, perhaps you could search for the urlpattern with the correct name instead?