I am attempting to learn Django development with Bluemix Cloud Foundry and Python 3.5.3.
I have a hello world Website running at this time. But I cannot get static files like CSS to be served.
I think my settings for finding static files are not correct.
My served page is meant to look like:
What I am getting is:
I get the correct result locally with Debug = True
in settings.py, but not with Debug = False
. I cannot get the correct result when pushed to Bluemix, regardless of the Debug setting.
My project folders are set up like this:
the django staticfiles app is in my Installed_Apps variable.
In my settings.py file I have:
...
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# STATICFILES_DIRS = [
# os.path.join(BASE_DIR, 'bluemixsite/static'),
# os.path.join(BASE_DIR, 'bluemixapp/static'),
# ]
STATICFILES_DIRS appeared to make no difference with finding static files.
The template page (being loaded) includes the following:
...
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'bluemixapp/stylesheet.css' %}" />
</head>
....
With Debug=False, when inspected in firefox, I can see this message under the style editor both locally and on bluemix:
The requested URL /static/bluemixapp/stylesheet.css was not found on this server.
So either I do not have the files in the correct location, or Django cannot resolve paths to the static files on the server.
I tried the collectstatic command which copied all static files into project_root/static/
folder but this made no difference.
Apparently Bluemix refuses to run linux terminals (they freeze or crash when starting) so I can't do anything at the server end that way.
I cannot load the static files onto a separate server.
Any suggestions would be appreciated.