Django can't load static files, even with correct settings

Today i faced a problem with static files. I was adding JavaScript and CSS to my project, but the app could not load it. It did find the files, but could not load them, because the app shows 404 code (see picture).

I made sure that i have these lines in my settings.py:

STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / 'static'

Then i made sure i ran collectstatic command and linked them in html template.

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

Anyway, i got 404 in console section of browser Google Chrome Console

This is the second time i'm facing this problem. On my previous little project as wel, I encountered the same problem. I tried to find solution to this problem from every corner of internet: this site, django forum and other forums. But i could not find any solution.

I have a thought that this problem may be with my laptop or OS maybe. My OS is Linux Ubuntu 22.04 LTS. If there is someone that encountered same problem or has any idea how to solve this problem, I would be glad.

Вернуться на верх