0
votes

Hey Guys, I have a problem, django canot find my static files when testing the page. Google Console errors,

*127.0.0.1/:10 GET http://127.0.0.1:8000/static/css/all.css net::ERR_ABORTED 404 (Not Found) and many other errors like that

My static files in settings.py;

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATIC_FILES_DIRS = [
os.path.join(BASE_DIR, 'btre/static')
]

my static files are properly, i mean double checked, in my project folder (i.e. btre/static/) did collect static command in manage.py but still getting errors. I also properly referenced the CSS and JS files in base.html as well;

{% load static %}
<!DOCTYPE html>
<html lang="en">

    <head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="{% static 'css/all.css' %}">
  <!-- Bootstrap -->
  <link rel="stylesheet" href="{% static 'css/bootstrap.css' %}">
  <!-- Lightbox -->
  <link rel="stylesheet" href="{% static 'css/lightbox.min.css' %}">
  <!-- Custom -->
  <link rel="stylesheet" href="{% static 'css/style.css' %}">
2

2 Answers

0
votes

Should it not be

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

?

0
votes

How stupid of me.

STATIC_FILES_DIRS = [
os.path.join(BASE_DIR, 'btre/static')
]

made an error above there. should have been like;

STATICFILES_DIRS instead of STATIC_FILES_DIRS