The mechanism for the ferromagnetic order of (Ga,Mn)As and (Ga,Mn)N is extensively studied over a vast range of Mn concentrations. We calculate the electronic structures of these materials using density functional theory in both the local spin density approximation and the LDA+U scheme, that we have now implemented in the code SIESTA. For (Ga,Mn)As, the LDA+U approach leads to a hole mediated picture of the ferromagnetism, with an exchange constant N β= -2.8 eV. This is smaller than that obtained with LSDA, which overestimates the exchange coupling between Mn ions and the As p holes. In contrast, the ferromagnetism in wurtzite (Ga,Mn)N is caused by the double-exchange mechanism, since a hole of strong d character is found at the Fermi level in both the LSDA and the LDA+U approaches. In this case the coupling between the Mn ions decays rapidly with the Mn-Mn separation. This suggests a two phases picture of the ferromagnetic order in (Ga,Mn)N, with a robust ferromagnetic phase at large Mn concentration coexisting with a diluted weak ferromagnetic phase.