Heroku not finding my static files with Django
Hello I'm on a fullstack course with the Code Instiute and both me and technical support have been stumped on this issiue:
After deploying on Heroku no css or js loads or runs.
error from chrome inspect console log:
turnpenny-fry-syndrome-98cd38841f84.herokuapp.com/:1 Refused to apply style from 'https://turnpenny-fry-syndrome-98cd38841f84.herokuapp.com/static/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
css is linked in html like so:
<link rel="stylesheet" href="{% static 'css/style.css' %}">
settings file:
STATIC_URL = "static/" STATICFILES_DIRS = [os.path.join(BASE_DIR, "static" ),] STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
Relative file path of my css file:
static\css\style.css
And Debug is always set to False when deploying.
Seemingly the error messages show the right path for the files both in vs code and on github, seems like now its Heroku not reading from github correctly???
Have grone through Django documentation: https://docs.djangoproject.com/en/4.2/ref/settings/#static-url https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/#django-admin-findstatic
both me and support staff on my course have many times checked my settings file, .python-verion file, base.html links and commented out js link so i can just focus on css first also, I checked config vars and they appear all correct.
I have since found the issue: Whitenoise was missing in Middleware.
While I did have Whitenoise installed and static files installed, I managed to miss adding
'whitenoise.middleware.WhiteNoiseMiddleware',
to the Middleware list within settings.py