设置setting文件

template即为真实的static文件夹

STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'templates').replace('\\','/'),
]

加载static文件夹

在html文件中加上load staticfiles,写在最外面

{% load staticfiles %}
<!doctype html>
<html>

添加路径

我在是样式里添加好了背景图片的路径

background-image: url("{% static "images/bgimg.jpg" %}");