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

1.7K
Visualizações
django Cannot find static/css files error 404

This problem seems to be widely known, however, most are old Q&A's and they do not solve my problem.

I am using Django 2.0.2 and when my simple web page is not rendering my bootstrap.css file because it simply cannot find it.

I am following this tutorial: https://simpleisbetterthancomplex.com/series/2017/09/11/a-complete-beginners-guide-to-django-part-2.html#static-files-setup

This is my file structure:

myproject/
 |-- myproject/
 |    |-- boards/
 |    |-- myproject/
 |    |-- templates/
 |    |-- static/
 |    |    +-- css/
 |    |         +-- bootstrap.min.css    <-- here
 |    +-- manage.py

This is my static variables defined in the settings.py file.

STATIC_URL = '/static/'

STATICFILES_DIR = [
    os.path.join(BASE_DIR, 'static'),
]

This is my home.html file as is with the bottom half cut out for brevity.

{% load static %}<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Boards</title>
    <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
  </head>
  <body>
    <h1>Boards</h1>

I have debugging set to true, and when I run my server and load it up, I am presented with the following: [08/Feb/2018 19:26:02] "GET /static/css/bootstrap.css HTTP/1.1" 404 1675

I am also not able to visit this URL as it states a 404 error too: http://127.0.0.1:8000/static/css/bootstrap.min.css.

I'm not sure as to why Django cannot find the .css file when I have it clearly stated in the above files. No other StackOverflow questions/answers have helped me either.

Open to suggestions; any help is much appreciated.

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

EDIT: It seems that the OP mispelled the STATICFILES_DIRS setting, missing an 'S'.

Within your Django app directory create a subdirectory static and then within that directory, create another one named the same as the name of your Django app. Then move your css directory inside that latest mentioned directory.

So, something like this:

- your_django_app
-- static
--- your_django_app
---- css
----- bootstrap.min.css

Then you'll be able to use in your templates like this:

<link rel="stylesheet" href="{% static 'your_django_app/css/bootstrap.min.css' %}">
over 4 years ago · Santiago Trujillo Relatório

0

As per @bonidjkic's comment: I believe that you misspelled the STATICFILES_DIRS setting (you're missing an 'S'), this was the problem.

Thank you ever so much, I feel so stupid as to how I had ever missed that.

over 4 years ago · Santiago Trujillo Relatório

0

on the setting.py file try using this syntax:

STATICFILES_DIRS = [ os.path.join (BASE_DIR, "static"), '/ Var / www / static /', ]

over 4 years ago · Santiago Trujillo 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