问题
Setting up static files in django has always been a nightmare to me. When it comes to dealing with django static content I get depressed and feel dumb and stupid. I never really cared about getting admin media files served as static ones since I barely use admin interface and there is no impact on performance.
It has worked quite ok with this dev setup until I upgraded to 1.4
settings.py
MEDIA_ROOT = 'd:/~Sasha/Portman/media/'
MEDIA_URL = 'http://localhost:8000/media/'
ADMIN_MEDIA_PREFIX = '/admin-media/'
urls.py
(r'^admin/', include(admin.site.urls)),
(r'^media/(?P<path>.*)$',
'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
I looked up django 1.4 "what's new" documentation from can't figure what it is I need to change to get things back on track...
回答1:
ADMIN_MEDIA_PREFIX is deprecated in Django 1.4. The admin uses the staticfiles app now which was introduced in Django 1.3. Also make sure you don't miss to setup the static file development view as described at the end of the documentation page.
来源:https://stackoverflow.com/questions/9960345/django-admin-static-files-stopped-working-after-upgrade-to-1-4