I am working on a blog website in django, where I can write articles. While developing I am simultaneously hosting it on pythonanywhere.com In dev server everything works perfect, but after deploying, I am facing a strange issue. My static files are loading for home page but are giving error-404 for all remaining pages.
While debugging, I found that for home page it searches files in path www.asdf.pythonaywhere.com/static which is correct But for a page say 'www.asdf.pythonaywhere.com/article/1/' it searches for static files in ''www.asdf.pythonaywhere.com/article/1/static' which is incorrect. I searched everywhere on the internet but couldn't find answer.
Here are my settings:
STATIC_URL = 'static/' STATIC_ROOT = 'static/'
This is how I am referring to static files:
<link href="{% static "vendor/bootstrap/css/bootstrap.min.css" %}" rel="stylesheet">
I guess the problem is that you are using relative addressing for your static_url and root. change it to this:
STATIC_URL = '/static/'
STATIC_ROOT = '/static/'
add '/' before your static urls