Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

263
Visualizações
Can't load JS static file, but style.css file still work

This is my error. The styles.css and index.js file in same folder name network. But the styles.css file is work, and index.js file doesn't work, it looking to my other project is Mail

[20/Feb/2022 14:17:59] "GET / HTTP/1.1" 200 1804
[20/Feb/2022 14:17:59] "GET /static/network/styles.css HTTP/1.1" 304 0
[20/Feb/2022 14:18:01] "GET /static/mail/inbox.js HTTP/1.1" 404 1667
[20/Feb/2022 14:18:01] "GET / HTTP/1.1" 200 1804

setting.py

STATIC_URL = '/static/'

index.html

{% extends "network/layout.html" %}
{% load static %}

{% block body %}
{% endblock %}

{% block script %}
    <script src="{% static 'network/index.js' %}" defer></script>
{% endblock %}

index.js

console.log('OK');

layout.html

{% load static %}

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>{% block title %}Social Network{% endblock %}</title>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
        <link href="{% static 'network/styles.css' %}" rel="stylesheet">
    </head>
    <body>
        <div class="body">
            {% block body %}
            {% endblock %}
        </div>
    </body>
</html>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You should add block script in layout.html

{% load static %}

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>{% block title %}Social Network{% endblock %}</title>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
        <link href="{% static 'network/styles.css' %}" rel="stylesheet">
    </head>
    <body>
        <div class="body">
            {% block body %}
            {% endblock %}
        </div>

      {% block script %}
      {% endblock %}

    </body>
</html>
about 4 years ago · Juan Pablo Isaza Relatório

0

add type to script and try it:

<script type="text/javascript" src="{% static "network/index.js" %}"></script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda