I
I
Ilya Trusov2017-04-05 19:59:35
Django
Ilya Trusov, 2017-04-05 19:59:35

How to work with static files in Django?

Hello. I do not understand why templates do not find statics in Django (1.11)
I do this.
Fundamentally! I create a static folder, throw statics there, in the settings I do this:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

In html I do this:
{% load staticfiles %}
<link rel="stylesheet" href="{% static 'css/style.css' %}">

Then I do:
python manage.py collectstatic
As a result, the file seems to have the correct link, but it is not located.
SGGGMLG.png
Here is the structure of the static folder:
6G7xpwD.png
I know that in each application you need to place a static folder and load it from there, as the documentation says, but this is a little crazy, do I really have to keep a copy of all statics in each application and run and edit everywhere every time I have it. Maybe I don't understand something, tell me?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2017-04-05
@artgrosvil

https://docs.djangoproject.com/en/1.10/howto/stati...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question