http://127.0.0.1:8000/static/apis/icons/random-svgrepo-com.svg
gives me error 404 not found.
settings.py
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles/')
STATICFILES_DIR = [
os.path.join(BASE_DIR, 'staticfiles/'),
]
MEDIA_URL = 'media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/media')
template.html
{% load static %}
<img src="{% static 'apis/icons/random-svg.svg' %}">
root urls.py
from django.conf.urls.static import static
from django.conf import settings
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Work directory:
I am running ./manage.py collectstatic
, and then run the server. But it doesn't show me my image.
My questions are:
- Difference between
STATICFILES_DIR
andSTATICFILES_DIRS
- What I am doing wrong? Why my static files doesn't appear to work fine?
Thanks!