Forums

Currently unable to access static files

Followed instructions on help page: 'How to setup static files in Django', including adding STATIC_URL = "static/" STATIC_ROOT = "/home/mbak000/hone_one/static" to the project's setting.py file and then running this command in the console: 'python3.10 manage.py collectstatic'. The error.log files says 'Not Found: /static/admin/css/base.css', plus 6 other similar, 'Not Found' messages for admin-related css and js files.

Maybe try loading files relative to the static dir, eg '/admin/css/base.css' rather than '/static/admin/css/base.css'. Since you have the static dir as the STATIC_ROOT setting

Thanks for the idea. How do I do that? Do I change my STATIC_URL and/or STATIC_ROOT in the settings.py file?

No, just change the path of the file you are loading

The css, img, and js files that come with the Django admin are located at /home/mbak000/hone_one/static/admin. The error message for one of the files says 'not found: /static/admin/css/base.css', which I don't understand because base.css is at /home/mbak000/hone_one/static/admin/css/base.css. I currently have the following settings: STATIC_URL = "static/" and STATIC_ROOT = os.path.join(BASE_DIR, "static") (i've also tried STATIC_ROOT = "/home/mbak000/hone_one/static". I'm sure this is an easy fix - can someone please say specifically what I should? (like spell out what new code to write or where to move the admin folder, if that's necessary). Thank you.

It works now. I needed to enter the URL and directory of the Static files on the Web tab in PythonAnywhere.

Thanks for letting us know