Forums

django static files not loading

I'm setting up a new django project and trying to get the static files to load. I have done the things outlined in https://help.pythonanywhere.com/pages/DjangoStaticFiles. Specifically I have set the STATIC_ROOT, run collectstatic, and set up the static files mapping. I am running in debug mode.

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")

the url table entry is /static/ and the home dir entry is home/sbw/scl/static I have checked that the files are on the server in the correct location. I have looked at the debug file https://help.pythonanywhere.com/pages/DebuggingStaticFiles/ for anything I missed

When I try to check the file individually I get an error page that complains about the url patterns: Page not found (404) Request Method: GET Request URL: https://sbw.pythonanywhere.com/static/admin/css/base.css Using the URLconf defined in scl.urls, Django tried these URL patterns, in this order:

admin/ microsoft/ [name='index'] dashboard/ [name='dashboard'] importaccounts/ [name='importaccounts'] The current path, static/admin/css/base.css, didn’t match any of these.

Do I need to add some kind of pattern to allow access to the static files or is something else going on?

We've got help pages on that:

Yes, I already looked at both of those (as noted in my question) and was not able to resolve the issue.

Could you show us the set up for the static files you have on the Web page? (If you don't want to, send us an email to support@pythonanywhere.com and we can continue there.)

I did show the setup. How else do you want to see it? "the url table entry is /static/ and the home dir entry is home/sbw/scl/static". From the files page here are the breadcrumbs /home/sbw/scl/static/. I don't know how else to show it.

It should be /home/sbw/scl/static not home/sbw/scl/static

Right you are. Thanks so much.

Glad to hear that you made it work!