Forums

Django error 503 static and media files by debug=False

Django

DEBUG = False

MEDIA_ROOT = os.path.join(DATA_DIR, 'media')

STATIC_ROOT = os.path.join(DATA_DIR, 'static')

Static files in pythonanywhere web panel:

URL: /static/

Directory: /home/username/projectname/static/

URL: /media/

Directory: /home/username/projectname/media/

reload server, but error 500 by static and media files

what am I doing wrong?

Did you run manage.py collectstatic command after updating settings?

yes

yes

Have a look at our help page that covers how to debug static files issues: https://help.pythonanywhere.com/pages/DebuggingStaticFiles/

i tried a lot but it doesn't help

As per that page, could you give an example of:

  • The URL which you expect to be able to load the static file from (eg www.mydomain.com/static/path/to/myfile.css)
  • The path where this file is stored on disk, in your PythonAnywhere account(eg /home/myusername/myproject/assets/path/to/myfile.css)
  • The relevant static files mapping from the web tab, the values for its URL and path settings (eg: URL /static/ maps to path /home/myusername/myproject/assets)