Klawens
Klawens

Reputation: 107

Django can't locate my static files

I deploy the static settings like this:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static/"),
]

And I got a static folder in root with some css files, I use the link like:

<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}css/station_list.css'">
<img src="{{ STATIC_URL }}images/logo.png">

The css path is correct but the html can't display the css style, and I check the terminal, it says:

Not Found: /raise/station/css/station_list.css'
Not Found: /raise/station/images/logo.png

Why the path is not /static/ but an app root? Thanks.

Upvotes: 0

Views: 91

Answers (1)

SOBIR N
SOBIR N

Reputation: 346

For calling static files like css or image {% static 'css/style.css' %} in your href attribute and {% load static %} place this in top of your template

Upvotes: 1

Related Questions