Home:ALL Converter>Static files are not loading in Django

Static files are not loading in Django

Ask Time:2021-09-12T02:26:13         Author:Muhammad Asim

Json Formatter

Why I am receiving files can't be found error while loading all the static files even after setting everything correctly.

ERROR

enter image description here

CODE:

Admin Section

- settings.py

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, '')

- urls.py

from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('Welcome.urls')),
    path('auth/', include('Authentication.urls')),
    path('ad/', include('Ads.urls')),
    path('user/', include('UserDashboard.urls')),
    path('admin/', include('AdminDashboard.urls')),
]

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

Apps Section

- template

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

- Folder Structure

enter image description here

Author:Muhammad Asim,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69145675/static-files-are-not-loading-in-django
yy