2014-11-09 95 views
0

在我的settings.py我有這樣的靜態設置:Django的樣式表DONOT鏈路與圖像文件

STATIC_ROOT = ' ' 

STATIC_URL = '/static/' 
STATICFILES_DIRS = (

os.path.join(BASE_DIR, 'static'), 
) 

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder', 
'django.contrib.staticfiles.finders.AppDirectoriesFinder', 
#'django.contrib.staticfiles.finders.DefaultStorageFinder', 
) 

我的項目結構是:

ProjectName 
    app1 
    app2 
    ProjectName 
    static 
     css 
     js 
     images 

而且我已經寫在CSS名爲style.css中:

input.search { width: 279px; border: none; background: #fff url(../images/input.gif) no-repeat; padding: 6px 10px; color: #1E67A8; font-weight: bold; } 

當我做到這一點它沒有顯示,我在我的style.css分配了圖像..

什麼問題?

+0

告訴ü可以通過URL或無法訪問此...? http:// localhost:8000/static/images/input.gif – 2014-11-09 08:11:35

+0

是的,圖像訪問從提到的網址... – 2014-11-09 11:49:32

+0

然後在CSS中做同樣的事情..看到我的答案下面 – 2014-11-09 12:31:10

回答

0

您可能需要這在你的settings.py

STATICFILES_DIRS = (
    'static', 
    os.path.join(os.path.dirname(__file__), '..', 'static'),) 
0

您可以訪問圖片網址CSS像

input.search { width: 279px; border: none; background: #fff url(/static/images/input.gif) no-repeat; padding: 6px 10px; color: #1E67A8; font-weight: bold; }