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

228
Visualizações
Django unable to find scripts in static folder

This might seem like a duplicate question but I dont whats going on but I have gone through stackoverflow and tried all the solutions but cant find the answer that I need. Here Django finds the style.css but cannot find the App.js and script.js literally located in the same folder as style.css. I cant seem to figure out the problem, I have wasted around 2 hrs trying to figure it out. UPDATE: I tried hard coding the path and still says it didn't find it while shows up when I do py manage.py findstatic.
Relevant HTML

{% load static %}
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
  <meta charset="UTF-8">
  <title>Reyanna</title>
  <link rel="icon" href="https://img.icons8.com/nolan/96/bot.png" type="image/icon type">
  <link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,600,700,800,900" rel="stylesheet">
  <link rel="stylesheet" href="{% static 'style.css' %}">
  <link rel="script" href="{% static 'App.js' %}">
  <link rel="script" href="{% static 'script.js' %}">
</head>

Settings.py

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    BASE_DIR / "home/static",
]

Folders

  • Home(Django App)
  • |-> static
    • |-> App.js
    • |-> script.js
    • |-> style.css
  • |-> templates
    • |-> index.html
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

UPDATE: I realized templates folder is in App directory

If your templates folder is in your app directory, then:

  • Delete this STATICFILES_DIRS = [BASE_DIR / "home/static",]
  • Leave STATIC_URL = '/static/' like it is
  • Leave TEMPLATES >> DIRS path empty.
  • Last, in your base.html or index.html, add <scripts>----</scripts> tags before the closing body tag like the following
<script src="{% static 'js/jquery.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
  • Clear your browser history including all cookies and reload server.

If it is not successful, I suggest to check for missing closing tag in your html or tag name typo.

But if templates folder is within project directory then do the following:

  • In settings.py >> TEMPLATES, paste DIRS path like the following
'DIRS': [os.path.join(BASE_DIR, 'templates')]
  • Also copy paste the following in the bottom of settings.py
STATIC_URL = '/static/'

STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)

MEDIA_URL = '/media/'

MEDIA_ROOT = BASE_DIR
  • Last, in your base.html or index.html, add <scripts>----</scripts> tags before the closing body tag like the following
<script src="{% static 'js/jquery.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
  • Clear your browser history including all cookies and reload server.

If it is not successful, I suggest to check for missing closing tag in your html or tag name typo.

For exact examples of both, visit my GitHub repo and have a look to settings.py and base.html

Templates folder inside App directory

Templates folder within project directory

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