Задать вопрос
@goozzy
student of java dev

Django doesn't see static files in folder. Why?

I was faced with a problem when django can't see static files and I'm getting 404 error every time visiting the page.

[05/Oct/2021 19:25:07] "GET /static/main/css/index.css HTTP/1.1" 404 1813


Here is my setting.py
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/


STATIC_URL = '/static/'

STATICFILES_DIRS = ( os.path.join('static'), )

# Default primary key field type


Another part was cut

HTML file
{% load static %}
<!DOCTYPE html>


<html>
<head>
    <meta charset="utf-8" />
    <title>Hello World</title>
    <link rel="stylesheet"  href="{% static 'main/css/index.css' %}" />
</head>

Another part was cut too

Project folder:
615c9e046e43c529782334.png

urls.py
from django.urls import path, include
from . import views

urlpatterns = [
    path('', views.index),
    path('about', views.about)
]
  • Вопрос задан
  • 558 просмотров
Подписаться 1 Простой 3 комментария
Решения вопроса 1
mohovoy
@mohovoy
Что-то там программирую, кто бы знал что именно?
Try to fix on:
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]


But it will be better if you read the documentation
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
Strikt Москва
от 100 000 до 180 000 ₽
ITK academy Саратов
от 75 000 ₽
Sim-Ba Pay Санкт-Петербург
от 180 000 ₽