【发布时间】:2018-10-23 17:11:42
【问题描述】:
我刚刚在 Ubunto 服务器上部署了我的 django 网站。但它不会加载任何静态文件。
settings.py:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),]
STATIC_ROOT = 'staticfiles'
nginx/站点可用配置:
server {
server_name 138.197.172.33;
access_log off;
location /staticfiles/ {
root staticfiles;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
错误:
...
[14/May/2018 05:28:28] "GET /static/vendors/underscore/underscore.js
HTTP/1.1" 404 113
[2018-05-14 05:28:29,252] base: WARNING - Not Found:
/static/vendors/bootstrap-notify-simple-wrapper/bootstrap-notify-
simple-wrapper.min.js
[14/May/2018 05:28:29] "GET /static/vendors/bootstrap-notify-simple-
wrapper/bootstrap-notify-simple-wrapper.min.js HTTP/1.1" 404 159
[2018-05-14 05:28:29,690] base: WARNING - Not Found:
/static/js/custom.js
[14/May/2018 05:28:29] "GET /static/js/custom.js HTTP/1.1" 404 93
[2018-05-14 05:28:30,236] base: WARNING - Not Found:
/static/js/converter.js
[14/May/2018 05:28:30] "GET /static/js/converter.js HTTP/1.1" 404 96
...
staticfiles 文件夹包括:
admin ajaximage css datatable dm2bn fonts images js static
tinymce vendors
【问题讨论】:
-
您是否运行了
python manage.py collectstaticmanagement 命令? -
是的,我愿意,但没有任何改变
标签: django nginx digital-ocean