Exercise 2: Why CSS Disappears When DEBUG=False — Possible Solution ==================================================================== WHY IT WORKS IN DEVELOPMENT ------------------------------ Per this chapter, Django's own dev server (runserver) serves static files automatically - but this behavior only happens while DEBUG=True. Throughout local development, this makes static file serving feel effortless and automatic, easy to take for granted. WHY IT STOPS WORKING WITH DEBUG=False ------------------------------ Per this chapter, Chapter 11's own production setup requires DEBUG=False, and the instant that flag flips, Django stops serving static/ files itself entirely - this isn't a bug in the CSS or a regression in the code, it's Django's own dev-only convenience simply no longer applying once the site is treated as a real production deployment. Nothing about the stylesheet itself changed; only whether Django is willing to serve it at all changed. THE FIX ------------------------------ Per this chapter, python manage.py collectstatic has to be run to gather every app's static files into STATIC_ROOT, and something else - WhiteNoise, or nginx directly - then has to actually serve files from that location, since Django itself won't once DEBUG=False. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly explains that Django's automatic static-file serving is tied specifically to DEBUG=True, correctly explains why flipping to DEBUG=False breaks it (not a CSS bug, a serving-behavior change), and correctly names collectstatic as the required fix (paired with an actual static file server).