help me plz! I am learning to build a blog , this bothers me so long
help me plz! I am learning to build a blog , this bothers me so long
That sounds like the config file you have is for a version of whitenoise that is different to the one you have installed. Either change your config file or install the version of whitenoise that the config file is for.
Put a note here for posterity - I spent a while trying to get WhiteNoise to work on PythonAnywhere but kept getting 404 errors for my static files - only the static files that WhiteNoise had compressed and added a hash to. I was using the exact same settings and code on my local machine with no problems, I made sure to collectstatic
constantly, PythonAnywhere was not serving my static files straight from disk, and strangest of all any static files without an auto-generated hash in them worked fine.
The answer was the PythonAnywhere default WSGI file. From the PythonAnywhere Django tutorial I had set up my WSGI file like this:
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())
Because WhiteNoise >= 4.0 doesn't touch the WSGI file, I didn't realize that this was a problem. It was conflicting somehow with the Django handler. By replacing it with the following, everything started working fine:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Great! Thanks for the explanation.