The provisions of this chapter shall apply to all district elections, except as otherwise provided by law, or as otherwise provided in the charter of any city or city and county in the matters concerning which the provisions of such charters are afforded controlling force and effect by the Constitution or laws of the state.