Django 1.5 static files strangeness

442 views
Skip to first unread message

Mike Dewhirst

unread,
Apr 5, 2012, 12:52:40 AM4/5/12
to django...@googlegroups.com
I'm getting odd static files 404 behaviour switching to DEBUG = False on
my Windows XP dev machine.

My staging server is Linux running under Apache and the same code and
the same version of Django and that is running fine with DEBUG = FALSE

See the 200 versus 404 info below ...

#################### manage.py runserver DEBUG = False ###########
Validating models...

0 errors found
Django version 1.5.dev17868, using settings 'strxs.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[05/Apr/2012 14:29:20] "GET /admin/company/company/2/ HTTP/1.1" 200 85287
[05/Apr/2012 14:29:21] "GET /admin/jsi18n/ HTTP/1.1" 200 2158
[05/Apr/2012 14:29:21] "GET /static/css/darker.css HTTP/1.1" 404 504
[05/Apr/2012 14:29:21] "GET /static/js/tiny_mce/tiny_mce.js HTTP/1.1"
404 504
[05/Apr/2012 14:29:23] "GET /static/js/tiny_mce/tiny_mce.js HTTP/1.1"
404 504
###################################################################


Note that when DEBUG = True a number of settings are printed.
#################### manage.py runserver DEBUG = True ###########
SETTINGS_DIR = C:/users/miked/py/strxs/strxs
APP_ROOT = C:/users/miked/py/strxs (root for all
app dirs)
FIXTURE_DIRS = C:/users/miked/py/strxs/fixtures
MEDIA_ROOT = /srv/www/strxs/media/ (store
uploaded images etc)
MEDIA_URL = <website>/media/ (to serve
uploaded images)
STATIC_ROOT = /srv/www/strxs/static/ (collectstatic
destination)
STATIC_URL = <website>/static/ (to serve css,
js etc)
STATICFILES_DIRS#1 = C:/users/miked/py/strxs/static/
STATICFILES_DIRS#2 = C:/users/miked/py/strxs/company/static/
TEMPLATE_DIRS#1 = C:/users/miked/py/strxs/templates/

Validating models...

0 errors found
Django version 1.5.dev17868, using settings 'strxs.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[05/Apr/2012 14:30:18] "GET /admin/company/company/2/ HTTP/1.1" 200 85271
[05/Apr/2012 14:30:19] "GET /static/css/darker.css HTTP/1.1" 200 274
[05/Apr/2012 14:30:19] "GET /admin/jsi18n/ HTTP/1.1" 200 2158
[05/Apr/2012 14:30:20] "GET /static/js/tiny_mce/tiny_mce.js HTTP/1.1"
200 207762
###################################################################

The workaround is obviously to use DEBUG = True on the dev machine

Might be a bug

Mike

Mike Dewhirst

unread,
Apr 7, 2012, 4:41:20 AM4/7/12
to django...@googlegroups.com
My bad. Not a bug.

In my urls.py ...

if settings.DEBUG:

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

from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns += staticfiles_urlpatterns()

... which is needed to find the static files and not wanted with Apache.

Sorry

Mike

Reply all
Reply to author
Forward
0 new messages