Home:ALL Converter>Django static files 404 error

Django static files 404 error

Ask Time:2017-12-10T19:25:58         Author:Elgin Cahangirov

Json Formatter

I'm trying to locate all bootstrap files in django project in only one folder and reference them. In order to do that I've added these lines to setting.py:

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

My base.html looks like this:

{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Muplay</title>
    <link rel="stylesheet" type="text/css" href="{% static'css/bootstrap.css' %}">
    <script src="{% static 'js/bootstrap.js' %}"></script>
</head>
<body style="background-color: #F2F2F5">
    {% include 'snippets/nav.html' %}
    <div class="container">
        {% block content %}{% endblock %}
    </div>
</body>
</html>

When I extend this base.html to other html files css and js file is loaded successfully in browser. But, problem is that, in terminal, django returns 404 error as follows:

[10/Dec/2017 14:03:27] "GET /static/js/bootstrap.js HTTP/1.1" 404 1759
[10/Dec/2017 14:03:27] "GET /static/css/bootstrap.css HTTP/1.1" 404 1765

Why django returns 404 code while those static files are successfully loaded in browser?

Author:Elgin Cahangirov,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/47738345/django-static-files-404-error
yy