I don't know why django can't load static files even though I have defined static_url, static_root, staticfiles_dirs and urlpatterns including static_root. I put static files in root_dir/static/ directory.
My templates also got right syntax with {% load static%} and {% static '...'%}
Please give me some advice on this.
Many thanks
This is my main urls file
from django.contrib import admin
from django.urls import path
from home import views as HomeViews
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('',HomeViews.index,name='index')
]
if settings.DEBUG:
urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)