我升級到Django 1.4,現在我的管理靜態文件將不會加載。我的設置文件的升級到Django 1.4,但管理員仍在尋找靜態文件的媒體目錄
相關的部分看起來像:
MEDIA_ROOT = os.path.join(SITE_ROOT, 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(SITE_ROOT, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
INSTALLED_APPS = (
# django apps
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
和我collecstatic-ED。
所以,現在的文件顯示在我的項目的靜態目錄,但是當我嘗試訪問,例如,http://localhost:8000/static/admin/js/actions.js我得到一個404「/usr/local/lib/python2.7/dist-packages/django/ 「不存在
爲什麼Django在我的媒體目錄而不是我的靜態目錄,我該如何解決它?
一切看起來不錯,除了1.4你不再需要'ADMIN_MEDIA_PREFIX'。我不認爲這會打破它,但刪除它,看看。 – 2012-04-17 21:55:38