最近部署Django项目到服务器,部署过centos和windows,常常是资源 加载不出来 ,下面是通用的解决方法html
项目目录jquery
项目名称为SourceManagelinux
静态文件目录为根目录下的templates/staticwindows
settings.py中配置centos
STATIC_URL = '/static/'服务器
STATICFILES_DIRS = [app
os.path.join(BASE_DIR, 'templates','static'),ide
##os.path.join(BASE_DIR, 'templates/static'), 千万不能这样写,这样写在linux上是加载不出来 的ui
]spa
html页面中
{% load static %}
<!doctype html>
<html>
<head>
<script src="{% static 'assets/js/jquery.min.js' %}"></script>
<script src="{% static 'assets/js/amazeui.min.js' %}"></script>
<script src="{% static 'assets/js/app.js' %}"></script>
这样就能加载出来 了