Edit: 301/404 error NOT 301/401
I'm trying to deploy a Django + Mezzanine app, but I'm running into a lot of 404 errors when serving static files (in production). The exact error is as follows:
2017-01-31 21:44:44,981 :Not Found: /static/custom/css/bootstrap.min.css/
2017-01-31 21:44:45,012 :Not Found: /static/custom/css/bootstrap-material-design.min.css/
2017-01-31 21:44:45,042 :Not Found: /static/custom/css/animate.css/
2017-01-31 21:44:45,072 :Not Found: /static/custom/css/dots.css/
2017-01-31 21:44:45,102 :Not Found: /static/custom/css/ripples.min.css/
2017-01-31 21:44:45,133 :Not Found: /static/custom/css/swiper.min.css/
My Chrome console displays the following:
/static/custom/css/bootstrap.min.css 301 (Permanent redirect)
.....and then below that i get:
/static/custom/css/bootstrap.min.css/ 404 (Not found)
.....notice the forward slash at the end???
My project structure is as follows:
robot/ ("robot/" is the main project folder where manage.py is)
- apps/
- app1/
- app2/
- robot/
- settings.py
- urls.py
- wsgi.py
- static/
- media/
- manage.py
- requirement.txt
Here are my settings.py:
PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__))
PROJECT_APP = os.path.basename(PROJECT_APP_PATH)
PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP
WSGI_APPLICATION = 'robot.wsgi.application'
ROOT_URLCONF = "%s.urls" % PROJECT_APP
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
MEDIA_URL = STATIC_URL + "media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))
My "Web" tab settings are as follows:
Source code:
/home/Robot/robot/
Working directory:
/home/Robot/
WSGI configuration file:
/var/www/robot_pythonanywhere_com_wsgi.py
Virtualenv:
/home/Robot/.virtualenvs/robot-virtualenv
My wsgi file is as follows:
import os
import sys
# add project folder to path
path = '/home/Robot/robot'
if path not in sys.path:
sys.path.append(path)
# Remove any references to your home folder (this can break Mezzanine)
while "." in sys.path:
sys.path.remove(".")
while "" in sys.path:
sys.path.remove("")
# specify django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'robot.settings'
# load default django wsgi app for Django >= 1.4
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
I have DEBUG = FALSE, so the PythonAnywhere server (nginx + uWSGI) must be serving the static files. I don't understand why I'm getting this 301 redirect error, which then appends a forward slash to my static file paths leading to a 404 error!
I've been banging my head against the wall for the past week trying to get the static files to work, but no progress so far. Everything works when I try to outsource static files through Amazon S3, but why is serving it on the same server with nginx + uWSGI not working for me? I have a "Beginners" account if this helps.
Help please!! :)