kramer65
kramer65

Reputation: 53843

Django static files aren't loading and runserver doesn't show 404s

I've got django admin working on my django website, but the static css files give 404s. I see this in the browsers network tab, but in the terminal where I run python manage.py runserver I see no output of any request being made whatsoever. This is what I see in the browser:

enter image description here

So I suppose there's something wrong with my STATIC_URL or STATIC_ROOT:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

I ran python manage.py collectstatic, which created a bunch of nested folders containing static files.

So I checked out the terminal output of the runserver command, expecting to see the 404s. But after I got the 404s in the browser I only see this in the terminal:

$ ./manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
March 03, 2021 - 20:19:44
Django version 3.0.11, using settings 'main.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

So at this point I'm lost as to how I can solve this. Why don't I see the requests in the terminal? The dev server is definitely working, because when I stop the dev server the site doesn't load at all anymore.

Any help in how to debug this would be welcome!

Upvotes: 0

Views: 1251

Answers (1)

Praneeth
Praneeth

Reputation: 76

The static files are handled differently in production and development If you are in Development mode, turn on the debug mode in the settings.py

If you are in Production you need to use servers like apache.

DEBUG = True

Upvotes: 4

Related Questions