31👍
You most likely have solved the problem, however this is for anyone else who has the problem in the future.
Most sites and people say that you need to update the ALLOWED_HOSTS
in settings.py
like so: ['www.beta800.net', '127.0.0.1']
(or ['*']
for a quick test, NOT for production).
For me, this didn’t solve the problem, though it is important to update ALLOWED_HOSTS
either way. My problem was that my app was missing the static files folders. If the logging shows you an error similar to this: UserWarning: No directory at:/app/static/ warnings.warn(u'No directory at: {}'.format(root))
this is the problem in your app as well. If that is the case, follow these steps:
-
Locally, change the
DEBUG
property insettings.py
toTrue
. -
Make sure you have the following properties set in
settings.py
:
# The URL to use when referring to static files (where they will be served from)
STATIC_URL = '/static/'
# The absolute path to the directory where collectstatic will collect static files for deployment.
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
-
Locally, add a folder named
static
to the root folder. -
Locally, run
python manage.py collectstatic
. This should create another folder in your app’s root folder calledstaticfiles
. -
Now you can set the
DEBUG
property insettings.py
toFalse
and deploy your app.
0👍
You most likely have solved this already, but for future users, you are most likely not including your staticfiles directory in your repo, and your host saas wouldn’t run that for you so you either
-commit your staticfiles to your repo; That’s not advisable.
-create a script of command to run on deployment and include creatstatic there.
-if the host service has a console like Heroku, you can just run it there.
-connect your host to your local console and check their docs for how to run py commands on your deployed environment