Forums

Django Static Files Help

Hi,

Getting the static files to work in django is driving me crazy hahaha

I have andycv.pythonanywhere.com/csharp and if you look at the page source the CSS file it's looking for is at

my page code: <link rel="stylesheet" type="text/css" href="{% static 'csharp/style.css' %}"/>

the link its outputting: <link rel="stylesheet" type="text/css" href="/static/csharp/style.css"/>

That's andycv.pythonanywhere.com/static/csharp/style.css which doesn't exist!

My Static file mapping in settings.py is:

STATIC_ROOT = os.path.join(BASE_DIR, "static")

STATIC_URL = '/static/'

Any ideas?

Thanks, Andy

You need to set up a static file mapping on the "Web" tab -- this help page should explain everything, but if you still have questions after implementing the changes on the page, just let us know.

Bingo! Sorry, I thought adding the static url in the web tab was a second method to getting this to work.

I added in the web tab: Url: /static/ Path: /home/myusername/myapp/static

worked perfectly.

Thanks, Andy