Django静态文件目录配置

参考:https://docs.djangoproject.com/en/3.0/howto/static-files/

编辑setting.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
INSTALLED_APPS = [
...
'django.contrib.staticfiles',
]

...

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
1
2
3
4
5
6
7
8
9
10
<!DOCTYPE html>
<html lang="zh">
{% load static %}
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>AppBlog.CN</title>

<link href="{% static 'layui/css/layui.css' %}" rel="stylesheet" type="text/css" />
<script src="{% static 'layui/layui.js' %}" type="text/javascript" charset="utf-8"></script>

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :