1
我被困了一段時間,我似乎無法得到它。在你說python manage.py collectstatic
是的,我已經完成了。 這是問題:我正在使用夾層的一種佈局。它似乎不像夾層文件與實體模板佈局合併。帶夾層和模板的django靜態url
在我的首頁上,CSS可以工作,但是如果我轉到/admin
頁面,那麼css會像這樣加載admin/static/mezzanine/some_css.css
。除了根主頁之外的任何東西都會加載css文件。所以我猜這是這條路,但我已經檢查了我的根路徑,這似乎是正確的?
settings.py
PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
# PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) also tried this
STATIC_URL ='static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
# STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, "solid/static"),) also tried this
STATICFILES_DIRS = (
os.path.join(os.path.realpath(PROJECT_ROOT), "solid/static"),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
)
urls.py
urlpatterns +=[]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
simplfied文件結構
app
---app
---solid
static
admin
css
mezzanine
templates
---static
admin
css
mezzanine
manage.py