django 应用本地bootstrap
django 应用本地bootstrap
一.django 应用本地bootstrap
1.先下载bootstrap包,解压放在statics目录下
2.把css,js,以及fonts 放在统计目录下,也就是:
statics/css
statics/js
statics/font
3.在settings.py 文件最后加上下面内容
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'statics'),
]
其中可以在os.path.join(BASE_DIR, 'statics'),后面添加多个目录。如:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'statics'),
os.path.join(BASE_DIR, 'bbs/statics'),
os.path.join(BASE_DIR, 'www/statics'),
]
这样的话,在html中选择的静态资源会从第一个statics目录中寻找,如果找到就直接返回,如果没有就继续从后面的目录中寻找
4.在html文件中应用
<link href="/static/css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="/static/css/dashboard.css" rel="stylesheet">
<script src="/static/js/jquery.js"></script>
<script src="/static/js/bootstrap.js"></script>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。