django admin static files stopped working after upgrade to 1.4

牧云@^-^@ 提交于 2019-12-10 16:47:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!