2014-09-18 26 views
0

這是我的項目設置的頁面Django的靜態CSS沒有被發現(發展)

BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 

STATIC_URL = '/static/' 

STATIC_ROOT = 'staticfiles' 

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', 
) 

HTML文件

{% load staticfiles %} 
<link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet"> 
<link href="{% static "css/scrolling-nav.css" %}" rel="stylesheet"> 

這裏是我的項目目錄佈局:

https://app.box.com/s/zurax1ytxt71jhi8ieaq

我以爲我已經完全設置了這一點,但是當我的模板html呈現時,CSS/JS似乎不起作用。有任何想法嗎?

+0

那你的HTTP服務器配置? – elmonkeylp 2014-09-18 22:00:57

回答

1

我的答案是基於你的項目目錄佈局。

刪除

STATIC_ROOT = 'staticfiles' 

,改變STATICFILES_DIRS這樣的:

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'), 
) 
+0

即使有這些,CSS仍然不會呈現。此外,當請求URL http://0.0.0.0:5000/static/css/bootstrap.min.css時,我收到404未找到的錯誤。有任何想法嗎? – ApathyBear 2014-09-21 01:52:34