[Fixed]-Django Cannot find static/css files error 404

11👍

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' %}">

2👍

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.

1👍

on the setting.py file try using this syntax:

STATICFILES_DIRS = [
os.path.join (BASE_DIR, “static”),
‘/ Var / www / static /’,
]

0👍

Do you need the “STATICFILES_DIR” variable in your case? It points to the same place so it’s redundant until you run it on something like nginx or Apache I would think, to have them server the static files.

Is django.contrib.staticfiles in you “INSTALLED_APPS” variable in your settings file?

Leave a comment