[Django]-GET /static/css/base.css HTTP/1.1" 404 1660 from Django for Beginners

3๐Ÿ‘

Try this:

Move the static folder from the project root into the particular App directory. Do that for all the apps you create as Django uses django.contrib.staticfiles which takes care of all static files in your project. As referenced here

๐Ÿ‘คAsiak

2๐Ÿ‘

make sure you have the file base.css in the css folder then for some weird reasons try using double-quotes.

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

2๐Ÿ‘

In Django, there is one root static directory which lives under the project directory (at the same level of apps directories),in addition to this, there are other static directories live under Apps directories, and for each app which needs to use static files, A static directory should be created under it to host its particular static staff, so make sure to create static directory under each app so its views and templates can access them and run collectstatic whenever new static staff is added to static directories.

make sure in Setting file that STATIC_DIRC = [ "BASE-DIR /[App-Name].static"] for each app has static directory, dont include the root static directory otherwise Django will throws an error

I have faced this issue and spent few hours looking for solution which I finally got and the credit goes to Asiak answer (mentioned above)

๐Ÿ‘คHusam Alhwadi

0๐Ÿ‘

I had the same issue for a while. As you have explained, your code is alright and files are placed in the right directories. However, what I found out to be my issue was not including the following in the app/urls.py

from django.conf import settings
from django.conf.urls.static import static

 urlpatterns = [
     # ... the rest of your URLconf goes here ...
 ]+ static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)

For a better explanation check out the documentation django-staticfiles documentation

๐Ÿ‘คKelly Kiiru

0๐Ÿ‘

close The Sever And Run it again

๐Ÿ‘คAli Alahdal

0๐Ÿ‘

"GET /static/css/base.css HTTP/1.1" 404 1660

First of all check out if base.css is placed in css directory.

๐Ÿ‘คRodrigo Munoz

Leave a comment