Static files(CSS) won't load after setting DEBUG = False


#1

The pages work fine on DEBUG=True but the moment I change it to False,
the CSS styling vanishes.
This is what I get in the console:
“GET /static/css/style.css HTTP/1.1” 404 1286

Here’s my settings.py:

import os
import os.path

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

.
.
.

DEBUG = True
.
.
.
STATIC_URL = '/static/'
STATIC_ROOT = ‘staticfiles’

STATICFILES_DIRS = (

os.path.join(BASE_DIR, 'static'),

)


#2

I think it’s due to Django only handling static files when DEBUG is false: https://stackoverflow.com/questions/5836674/why-does-debug-false-setting-make-my-django-static-files-access-fail

Do you have a server set up for deploying your site? I can help figure out how to get it working to serve static files if you let me know if you’re on Heroku or similar.


#3

Currently testing on local server.
Thanks for the answer.