Low-density polymer foams pre-ionized by a well-controlled nanosecond pulse are excellent plasma targets to trigger direct laser acceleration (DLA) of electrons by sub-picosecond relativistic laser pulses. In this work, the influence of the nanosecond pulse on the DLA process is investigated. The density profile of plasma generated after irradiating foam with a nanosecond pulse was simulated with a two-dimensional hydrodynamic code, which takes into account the high aspect ratio of interaction and the microstructure of polymer foams. The obtained plasma density profile was used as input to the three-dimensional particle-in-cell code to simulate energy, angular distributions and charge carried by the directional fraction of DLA electrons. The modelling shows good agreement with the experiment and in general a weak dependence of the electron spectra on the plasma profiles, which contain a density up-ramp and a region of near-critical electron density. This explains the high DLA stability in pre-ionized foams, which is important for applications.