[Answer]-Fetch Static files from Server in Django


this is the url of the static that will be used in template STATIC_URL = '/static/'

add the desire path to the static files dirs var

STATICFILES_DIRS = ('/var/www/my_site/my_path',)

please note that the path doesn’t end with backslash

please note that the trailing comma

now in your templates use

    {% load staticfiles %}
    <link href="{% static "css/style.css" %}" rel="stylesheet">

this link will resolve to my_site/static/css/style.css
and will be in the folder /var/www/my_site/my_path/css/style.css

maps to

STATICFILES_DIRS : /var/www/my_site/my_path/css/style.css


Leave a comment