In this paper, we study the ultracold atoms in optical lattice with a weak random external potential by an extended Bose–Hubbard model. When the on-site interaction is strong enough, the model can be mapped to the XXZ model. Then the mean-field theory is applied and we get the zero- and finite-temperature phase diagrams in different optical parameters. The differences between the systems with and without disorder were found, and the Bose-glass phase may exist in the system with disorder.