편집 :
내가 약간 떨어져 있었다 ... STATIC_ROOT 장고가 모든 정적 파일을 수집 할 디렉토리를 의미합니다. STATICFILES_DIRS는 정적 파일에 대한 검색 경로 목록입니다. 이 같은 :
이
settings.py :
# 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 = PROJECT_ROOT + 'static/'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"C:/www/django/static",
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
및 URL을 추가가 urls.py를 위해 :
urlpatterns += staticfiles_urlpatterns()
는
ORIGINAL 답 :
이 될 수 있습니다 아주 혼란 스럽네. MEDIA_ROOT 디렉토리는 파일 업로드 양식을 통해 업로드 된 파일 용입니다. 클라이언트 요청 (예 : 스타일 시트, 스크립트 및 이미지)을 통해 직접 액세스 할 수있는 실제 파일의 경우 STATIC_ROOT 및 STATIC_URL을 사용해야합니다. STATIC_ROOT는 절대적인 경로 여야합니다.
settings.py
# the url: myserver.com/static/
STATIC_URL = '/static/'
# refers to this directory:
STATIC_ROOT = '/home/user/static server files'
의 당신이 "/ 홈/사용자/정적 서버 파일/CSS는 /"다음과 같이 그들에게 참조에 CSS를 넣어 가정 해 봅시다 :
base.html
<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css" />
파일이 렌더링 된 후 파일의 HTML 소스를 검사하고 "href"가 가리키는 내용을 확인하십시오. 어쩌면 무엇이 잘못되었는지 알 수 있습니다. – grim