1. 程式人生 > >django 載入css等靜態檔案

django 載入css等靜態檔案

網上很多都不實用,就在settings末尾加上如下程式碼就可以了。

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.
    os.path.join(BASE_DIR, 'static/'),
)

引用,static前面一定要加‘/’
<script src="/static/js/bootstrap.min.js"></script>