django 加载css等静态文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Grandaunt/article/details/80852444

网上很多都不实用,就在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>

猜你喜欢

转载自blog.csdn.net/Grandaunt/article/details/80852444