0

I have a problem with static css files. I added to your application (in django 1.8) Page 404 - 404 page template and code in a file urls.py:

handler404 = 'django.views.defaults.page_not_found'

My STATIC_ROOT:

STATIC_ROOT = os.path.join(BASE_DIR, 'public_assets') 

In settings.py file, I have the code:

Debug = False
ALLOWED_HOSTS = ['*',]
ALLOWED_HOSTS = ['localhost', '127.0.0.1',] - also doesn't work

After starting website, do not load styles and pictures.

mark
  • 653
  • 1
  • 10
  • 23
  • Do you have a `STATIC_ROOT` set? – rnevius Jun 20 '15 at 12:18
  • yes, I have: `STATIC_ROOT = os.path.join(BASE_DIR, 'public_assets')` – mark Jun 20 '15 at 12:24
  • And you have run `collectstatic`? You should post your staticfiles settings above – rnevius Jun 20 '15 at 12:25
  • Yes, I run collectstatic, but nothing happend – mark Jun 20 '15 at 12:28
  • possible duplicate of [Django can't find staticfiles with Debug=False and Allowed\_Hosts](http://stackoverflow.com/questions/28443991/django-cant-find-staticfiles-with-debug-false-and-allowed-hosts) – spectras Jun 20 '15 at 12:37
  • is this run on a production server? or locally? if it is local then the comment below will solve your problems. If it is deployed then you need to set a rule so that the web server (apache or nginx) know where to pull your files from. (alias to their location should work just fine) – chaos Jun 20 '15 at 13:08

1 Answers1

0

Not sure this will work are not

if not settings.DEBUG:
    urlpatterns += patterns('',
                 (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT, 'show_indexes':True}),
            )

add above at the end of root urls.py and run collectstatic

Ravi Kumar
  • 1,769
  • 2
  • 21
  • 31
  • 1
    Do not do that. Ever. It is both dangerous and very inefficient. Even the documentation of that view says so. You should be using a webserver in front of Django to (among other things) handle static files. – spectras Jun 20 '15 at 12:39