1.在manage.py平级目录下建立一个static文件夹存放css,js,images文件夹:
bash-3.2# ls
EasyWeb mainsite static
db.sqlite3 manage.py templates
bash-3.2# cd static
bash-3.2# ls
css images js
bash-3.2#
2.进入settings.py配置static路径:STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
3.将html中的路径改成相等路径:
html>
<head>
<meta charset="utf-8"/>
{% load staticfiles %}
<title>Game</title>
<link rel="stylesheet" href="{% static "css/style.css" %}" />
<script src="{% static "js/jquery-3.1.1.min.js" %}"></script>
<script src="{% static "js/handle.js" %}"></script>