LINE Chatbot 建立遊戲化體驗APP|Day5.5 CSS加載沒有成功怎麼辦?

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 like so: ['', ''] (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:

  1. Locally, change the DEBUG property in to True.
  2. Make sure you have the following properties set in
# 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.
    os.path.join(BASE_DIR, 'static'),

# Simplified static file serving.
  1. Locally, add a folder named static to the root folder.
  2. Locally, run python collectstatic. This should create another folder in your app’s root folder called staticfiles.
  3. Now you can set the DEBUG property in to False and deploy your app.


Leave a Comment