R
R
raw12018-05-04 21:14:23
Django
raw1, 2018-05-04 21:14:23

Why are static files not found?

The browser cannot find static files at 127.0.0.1:8000/static/css/style.css.
Here's how I connected

{% load staticfiles %}
<link rel="stylesheet" href="{% static 'css/style.css' %}"><img src="https://habrastorage.org/webt/5a/ec/a2/5aeca2e6de8e6594465263.png" alt="image"/>

Here is the folder hierarchy
5aeca2e5d27ba725767252.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
raw1, 2018-05-04
@raw1

It turned out like this: if you create a static folder outside the application, but globally, then you need to write the following in settings.py

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question