Travis Tay
Travis Tay

Reputation: 350

How do i control static directory resources

<script src="./home/static/js/2.d754fc32.chunk.js"></script>

Currently my html file points to this. What static variable django setting.py do I declare to make the HTML point to

<script src="./home/static/static/js/2.d754fc32.chunk.js"></script>

currently in setting.py

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, '../frontend/build')
]

STATIC_ROOT = '/var/www/web/home/static/'
STATIC_URL = 'home/static/'

My build folder contains a static file inside as well.

Upvotes: 0

Views: 48

Answers (1)

lucasrf27
lucasrf27

Reputation: 360

if STATICFILES_DIR is in the right place:

You just have to {% load 'static' %} on the top of your html (after extend), and to set the css file:

    <link rel="stylesheet" type="text/css" href="{% static '/style.css' %}">

if you want a img from there would be:

<img src="{% static '<PathOfImage>/img.png' %}">

Upvotes: 1

Related Questions