Forums

Cannot serve static files django, tried every tutorial

I am trying to deploy my static files from my django app using python everywhere. I have followed 3 different tutorials now and none of them have worked.

my STATIC_URL is set to /static/ and my STATIC_ROOT is '/home/coursePlanner/CoursePlanner/static'

I collected all static files to the static root folder ('/home/coursePlanner/CoursePlanner/static) and If I use the python anywhere file broswer they are certainly all there.

in my python anywhere WSGI file, path is set to '/home/coursePlanner/CoursePlanner' and os.environ['DJANGO_SETTINGS_MODULE'] is set to 'CoursePlanner.settings'. Finally, in the static files section of the webapp settings, URL = '/static/' and directory=/home/coursePlanner/CoursePlanner/static. When I open my webpage none of my static files load. Furthermore If I go to http://courseplanner.pythonanywhere.com/static/css/styles.css I get the following page:

Page not found (404) Request Method: GET Request URL: http://courseplanner.pythonanywhere.com/static/css/styles.css Using the URLconf defined in CoursePlanner.urls, Django tried these URL patterns, in this order:

admin/

[name='courseplanner-planner']

validate/

getRec/

search/

reqBarHandler/

getUnits/

The current path, static/css/styles.css, didn't match any of these.

but if i go to the request URL in the python anywhere file manager, the file is present literally at that exact URL. What is going on? Any help would be greatly apperciated as Ive literally spent almost two full days trying to fix this now

ah- I took a look at your webapp config- your static url mapping is set to 'planner/static'. take out the quotes and reload?

Hi

I've got exactly the same issue on http://deejaym.pythonanywhere.com/. The "webapp config" file you're talking about is that the wsgi.py file, as I can't see any static URL mapping on it.

Thank you for any help you can give.

No, the webapp config is what you change on the "Web" page inside PythonAnywhere. The static files table is about halfway down. If you haven't already, you might want to take a look at our help page on how to setup static files in Django.

the problem is with urls ,you could have posted your urls so that we can point out the problem

What do you mean by "you could have posted your urls"?