Search code examples
pythondjangostatic-linking

Django Static Files - No error but still doesnt load or change css


It seems like this is an incredibly common issue and I've read the docs and tried all solutions and multiple youtube videos, but can't find a solution.

When I run the development server, my static files don't load but my terminal doesn't raise any errors either.

File layout: File Structure

SETTINGS.PY

STATIC_URL = '/staticfiles/'
MEDIA_URL = '/images/'

STATICFILES = [
    os.path.join(BASE_DIR, 'staticfiles'),
]

TERMINAL OUTPUT:

July 15, 2020 - 21:02:47
Django version 3.0.8, using settings 'mywebsite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[15/Jul/2020 21:02:51] "GET / HTTP/1.1" 200 148
[15/Jul/2020 21:02:51] "GET /staticfiles/css/main.css HTTP/1.1" 404 1672
[15/Jul/2020 21:02:51] "GET /staticfiles/images/headshot.JPG HTTP/1.1" 404 1693

Solution

  • Change this to

    STATICFILES = [
    os.path.join(BASE_DIR, 'staticfiles'),
    ]
    

    to this

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

    and make sure the name of the folder you have created for the static files is 'staticfiles'