jem
jem

Reputation: 51

cannot read static files after deploying my project on pythonanywhere PYTHON DJANGO

I dont know if I did this right but during development phase I placed all my static files on my project's main directory, it looks like this:

myproject

now my settings.py file looks like this:

STATICFILES_DIRS = [BASE_DIR / "static"]

STATIC_URL = '/static/'

after I deployed my project into pythonanywhere I added STATIC_ROOT:

STATIC_ROOT = '/home/jeremiramos/cvs/staticfiles/'

it does copy my static files to staticfiles folder when I do collectstatic on pythonanywhere console but it cannot read/load the static files I used on each and every page including admin page.

and my staticfiles settings on pythonanywhere looks like this: enter image description here

I checked my console and I got some errors:

Refused to apply style from 'http://jeremiramos.pythonanywhere.com/static/css/index.css/' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

I've tried checking the forums of pythonanywhere.com but it doesn't seem to help.

Can anyone please explain what did I do wrong and what should I do? Thank you!

Upvotes: 0

Views: 452

Answers (1)

caseneuve
caseneuve

Reputation: 476

Since http://jeremiramos.pythonanywhere.com/static/css/index.css loads the actual file, it means that static file mappings are OK. Trying the url with trailing slash (as in the error message you've shown) gives 404 and MIME type error message might be a symptom of it. Remove trailing slash from the url and check if that solves the issue.

Upvotes: 0

Related Questions