Search code examples
pythondjangobrowserbrowser-cachedjango-staticfiles

How to stop Django from serving files locally?


I need to prevent local Django/runserver from serving my static files (I want to test whitenoise locally). The --nostatic flag is supposed to do just that.

python manage.py runserver --nostatic

But I still get 200s (successful) for my static files. So then I set debug = False but still get 200s! I even commented out 'django.contrib.staticfiles' from INSTALLED_APPS. But this did not work either. How could my static files still be served successfully - it's usually not this hard to break things. Perhaps I am misunderstanding what nostatic actually does; I was expecting to get 404s.


Solution

  • Resolved in the comments, but for future reference the answer was to make sure that whitenoise.middleware.WhiteNoiseMiddleware was removed from the MIDDLEWARE list.