We present a joint theoretical and experimental study of the oxygen K-edge spectra for LaFeO₃ and homovalent Ni-substituted LaFeO₃ (LaFe₀.₇₅Ni₀.₂₅O₃), using first-principles simulations based on density-functional theory with extended Hubbard functionals and x-ray absorption near edge structure (XANES) measurements. Ground-state and excited-state XANES calculations employ Hubbard on-site U and inter-site V parameters determined from first principles and the Lanczos recursive method to obtain absorption cross sections, which allows for a reliable description of XANES spectra in transition-metal compounds in a very broad energy range, with an accuracy comparable to that of hybrid functionals but at a substantially lower cost. We show that standard gradient-corrected exchange-correlation functionals fail in capturing accurately the electronic properties of both materials. In particular, for LaFe₀.₇₅Ni₀.₂₅O₃ they do not reproduce its semiconducting behaviour and provide a poor description of the pre-edge features at the O K edge. The inclusion of Hubbard interactions leads to a drastic improvement, accounting for the semiconducting ground state of LaFe₀.₇₅Ni₀.₂₅O₃ and for good agreement between calculated and measured XANES spectra. We show that the partial substitution of Ni for Fe affects the conduction-band bottom by generating a strongly hybridized O(2p)-Ni(3d) minority-spin empty electronic state. The present work, based on a consistent correction of self-interaction errors, outlines the crucial role of extended Hubbard functionals to describe the electronic structure of complex transition-metal oxides such as LaFeO₃ and LaFe₀.₇₅Ni₀.₂₅O₃ and paves the way to future studies on similar systems.