I am trying to run the app with DEBUG=False
Below is my setting file configuration
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static/")]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles/')
After running python manage.py collectstatic, all the static files in the app path are copied to staticfiles directory (mentioned in STATIC_ROOT
path).
When loading the webpage, the static files are failed to get load.
Error message:
GET /static/dist/bootstrap-4.0.0-dist/js/bootstrap.min.14d449eb8876.js HTTP/1.1" 404 77
GET /static/dist/bootstrap-select/js/bootstrap-select.min.31f649694651.js HTTP/1.1" 404 77
GET /static/js/base.1332bbb46ac5.js HTTP/1.1" 404 77
GET /static/crsummary/dist/amcharts4/core.ea1ec0eb6727.js HTTP/1.1" 404 77
Looking at the error message, apps is trying to load the bootstrap.min.14d449eb8876.js
from path /static/\*/\*
but the actual file location is staticfiles/\*/\*
I am not sure what configuration that I have missed out here.
static/
?python manage.py collectstatic
simply takes all of your static files and puts them into one folder (staticfiles/
in your case), but it doesn't mean they will be served from there. As @ToanQuocHo asked, which server are you using? - Sam Creamerrunserver
command. If you still want to follow this way, make sure that your static url config on yoururls.py
is not stay insideif settings.DEBUG:
condition block. But I really not recommend you to even try this. - Toan Quoc Ho