Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No static files when DEBUG is False

I've some problem with deployment my application to production server. If I've set in settings.py

DEBUG = True
TEMPLATE_DEBUG = DEBUG

then everything works ok, but if I change settings to:

DEBUG = False
TEMPLATE_DEBUG = DEBUG

then my app is broken. I don't see static files (js, css, ...) and in admin panel I'm not able to add/edit my registered models. Do you have any advices how can I resolve this issue?

My envoirment:

  • Python 2.7.3
  • Django 1.4.1
  • Nginx 1.2.3
  • uwsgi 1.3
like image 299
Grzegorz Avatar asked Dec 20 '22 15:12

Grzegorz


1 Answers

You should read: Serving static files in production.

At least it sounds like you are relying on the helper view staticfiles_urlpatterns() from contrib.staticfiles which is only intended for 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.

like image 199
arie Avatar answered Dec 23 '22 05:12

arie