[4.2] Fixes #5216 [FIX 2]

By modifying the behaviour introduced by 6e672d708b1baffee6210e12be2d3e1f5be1a64e, this fixes #5216. I also have an alternative fix available. I don't know which way you'd prefer @taylorotwell.