I very recently replaced my rotors with Detroit axle rotors. I see that whenever I'm not using the car for even just a day or two, rust accumulates on it.
Now even after I use it, the brake pads clean it off but the middle part where the break pads don't touch stays rusty.
Is there an spray or something I can use to prevent rust on the rotors?
As long as your braking is not impacted, I wouldn’t worry about it. See below:
.
https://carkiller.com/scottykilmer/qa/rusty-rotors/#post-175067
the middle part where the break pads don't touch stays rusty.
it's supposed to be. Look at some other cars.
Short answer is no. Anything you spray risks decreasing the friction (stopping power) of the brakes. You would either have to install coated pads or just live with it (but it’s generally harmless).
@dad2lm2, I think, but may be mistaken, that what he's concerned about is the appearance of the rotors in the areas not swept by the brake pads. On a vehicle where the brake rotors have high visibility the rust can affect overall appearance. That's what coated rotors are for.
Is there an spray or something I can use to prevent rust on the rotors?
You would need to install coated rotors designed to resist rust in the non-contact areas.
Also, you left out a few details.

I didn't add these details as the question of not car specific.
Any coating I can spray now?
I didn't add these details as the question of not car specific.
Any coating I can spray now?
You never know what detail might be important.
About all you could try is some kind of high-temperature rust-resistant paint but I doubt it would hold up long.
Motorcycles generally use stainless steel on their brake discs. It probably costs a little more, and perhaps they need to be a bit larger to compensate for a difference in friction from steel vs stainless. But I can attest that they work quite well - and look better.
the question of not car specific.
I'm confused. I thought you were asking us for advice, not the other way around. Should we just let you answer the questions here?
We will nag you about it, so I suggest following the posting instructions every time.
I think what OP was saying there was that his question was not car model specific so he didn’t bother providing all the vehicle details.
I understood what OP said. The posting instructions are there for a reason.