第一步需要配置:
先成一个python Package = static文件夹:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>主页</title>
<link rel="stylesheet" type="text/css" href="/static/css/index.css">
</head>
{% load static %}
<body style="background-image: url({% static 'image/map_bg.jpg' %});">
<h1>主页</h1>
{% for key in ceshi_list %}
<p>{{ key }}</p>
{% endfor %}
</body>
<script type="text/javascript" src="/static/js/index.js"></script>
</html>
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
('css', os.path.join(STATIC_ROOT, 'css').replace('\\', '/')),
# ('js', os.path.join(STATIC_ROOT, 'js').replace('\\', '/')),
('images', os.path.join(STATIC_ROOT, 'images').replace('\\', '/')),
)