Reputation: 51361
This is very very weird.
On my dev machine, everything seems fine when I set DEBUG=True, but If I turn it off, it then breaks.
I can see the requested URLs are exactly same. What are the possible reasons for this?
In url
+ static("static", document_root= STATIC_ROOT )
The STATIC_ROOT is the absolute path to static folder, it's all right, cost it works when debug is turned on.
Upvotes: 1
Views: 818
Reputation: 9726
From Django docs regarding serving static files in development:
This will only work if DEBUG is True.
That's because this view is grossly inefficient and probably insecure. This is only intended for local development, and should never be used in production.
In short, if you are using devserver and DEBUG
is False
, static files won't be served.
Upvotes: 3
Reputation: 51361
While I fixed this by replace that url config by
url(r'^static/(?P.*)$', 'django.views.static.serve', { 'document_root': STATIC_ROOT }),
But I want to know why?
Upvotes: 1