B
B
Boldy2014-11-25 03:41:17
Django
Boldy, 2014-11-25 03:41:17

Where does the countdown start when specifying STATIC_URL in settings.py in django?

I have a project with the following hierarchy:

-myproject
--myapp1
--myapp2
--myapp3
--projectapp
---settings.py
---wsgi.py
---urls.py
--static_content
---media
---static
----css
--templates
---*.html

html in templates contains the following pointer to css:
<link rel="stylesheet" href="{{ STATIC_URL }}css/base.css" type="text/css">

What path should be specified in settings.STATIC_URL and how is it calculated? I tried to follow the pycharm prompts, but to no avail.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Dunayevsky, 2014-11-25
@Boldy

STATIC_URL is the part of the URL where the static path will start. Suppose
now, when parsing the URL, Django will immediately understand that the view requests
are static content and you don’t need to do anything there, you just need to return the file.
In addition to these parameters in settings.py for statics, you also need to specify the PATH_TO_STATIC parameter - this is the folder where Django
will add all static files when executing the command.
But in each application, I usually do this:

  • create static folder
  • in it I create a folder with the name of the application so that when collecting statics there is no porridge
  • I put the necessary libraries in the folder, etc.
Here is a full analysis of this issue (ENG).
Well, do not forget to write the tag at the beginning of the templates:
Then the links will work:
<link rel="stylesheet" href="{% static 'desktop/libs/bootstrap/css/bootstrap.css' %}"/>

A
Andrey K, 2014-11-25
@mututunus

Count starts from STATIC_ROOT

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question