Home > Blockchain >  Django: cannot import CSS file from static
Django: cannot import CSS file from static

Time:10-04

Django returns 404 error code in terminal logs while trying to import style.css file

Hi, I have problem with loading static files. Error occurred in my main HTML file (frame.html - base for other files). I made everything for correct work of static files, here's all of the applications (code, images) to my problem:

File system:

├── jdn
   ├── __init__.py
   ├── asgi.py
   ├── settings.py
   ├── urls.py
   └── wsgi.py
├── main
   ├── __init__.py
   ├── admin.py
   ├── apps.py
   ├── forms.py
   ├── models.py
   ├── pdf.py
   ├── templates
      └── main
          ├── create.html
          ├── frame.html
          ├── main.html
          ├── minauth.html
          ├── report.html
          ├── searchinit.html
          ├── searchres.html
          ├── univerauth.html
          └── viewuser.html
   ├── tests.py
   ├── urls.py
   └── views.py
├── manage.py
├── media
   └── main
      ...
└── static
  ├── admin
    ├── css
      ...
  └── main
    └── css
      └── style.css

urls.py(core):

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('', include('main.urls')),
    path('admin/', admin.site.urls),
]   static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)   static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

urls.py(app):

from django.urls import path

from . import views

urlpatterns = [
    path('', views.main, name='main'),
    path('token/', views.get_token, name='get_token'),
    path('create/', views.create_user, name='create_user'),
    path('search/', views.search_user, name='search_user'),
    path('token_report/', views.get_min_tok, name='get_min_tok'),
    path('report/', views.view_report, name='view_report'),
    path('view/<int:id>', views.view_user, name='view_user')
]

settings.py:

import os
from pathlib import Path


BASE_DIR = Path(__file__).resolve().parent.parent


SECRET_KEY = 'django-insecure-##=mjtuei4ry@#t5 (!)$fd@v=7_ubr-w#%1(0#$           
  • Related