0
votes

ive set my STATIC_ROOT dir in my settings.py. The shell print the path right where the files are located. But on rendering template on /comp/xyz the static files wont be loaded.

http://127.0.0.1:8000/static/js/jquery.min.js

This is the link rendered by STATIC_URL. its right. But no files.

>>> print(settings.STATIC_ROOT)
/home/mandaro/django/comp/static/
>>> 

there are all my staticfiles. So when i insert {{ STATIC_ROOT }}css/jquery.min.js on my templates. Why is this not working? Any some idea?

1
is it the debug webserver? are you using staticfiles_urlpatterns to serve those? - DRC
youp. debug webserver. no staticfiles_urlpatterns. only a STATIC_ROOT and STATIC_URL. - oranj33

1 Answers

0
votes

you should really read the documentation about serving static files.

Anyway probably you must add something like this in your urls:

from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

if settings.DEBUG:
    urlpatterns += staticfiles_urlpatterns()
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)

EDIT:

After your edit I saw that you are using {{ STATIC_ROOT }} instead of {{ STATIC_URL }} , is that a typo? Also I really advice you to switch to the {% static %} template tag, that because it is more portable with different storages.