[Answered ]-Static files don't load in django framework

1👍

add this in your code

import os

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]

0👍

try to add this in urls.py but this is only work when we posting any images from templates and stored in static files

urlpatterns = [
    path('admin/', admin.site.urls),

]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

also try this

comment your STATIC_ROOT = os.path.join(BASE_DIR, 'static')

0👍

update settings.py

TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [os.path.join(BASE_DIR, 'static')],
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                ],
            },
        },
    ]

Leave a comment