首先,我不知道这是我的问题还是其他人的问题。我的django admin制作版(我在网站上使用)与我在个人电脑上吃午餐时看到的不同。
您可以在两张图片中看到差异:
local version
(127.0.0.1:8000)
production version
(我的网站)
我想提一下:
我的
settings.py
:
STATIC_ROOT = '/home/django/django_project/django_project/static'
STATIC_URL = '/static/'
关于路径:
root@myuser:/home/django/django_project/django_project/static# ls
admin css fa fonts img js
运行管理面板时的控制台日志显示与管理面板相关的静态文件,如jquery。js无法正确渲染。
mywebsite.com/:12 GET https://mywebsite.com/static/admin/js/vendor/jquery/jquery.js net::ERR_ABORTED
mywebsite.com/:18 GET https://mywebsite.com/static/admin/js/vendor/xregexp/xregexp.js net::ERR_ABORTED
mywebsite.com/:199 GET https://mywebsite.com/static/admin/js/change_form.js net::ERR_ABORTED
mywebsite.com/:208 GET https://mywebsite.com/static/admin/js/prepopulate_init.js net::ERR_ABORTED
mywebsite.com/:12 GET https://mywebsite.com/static/admin/js/vendor/jquery/jquery.js 404 (Not Found)
jquery.init.js:7 Uncaught ReferenceError: jQuery is not defined
at jquery.init.js:7
(anonymous) @ jquery.init.js:7
actions.js:4 Uncaught TypeError: Cannot read property 'fn' of undefined
at actions.js:4
at actions.js:144
(anonymous) @ actions.js:4
(anonymous) @ actions.js:144
prepopulate.js:2 Uncaught TypeError: Cannot read property 'fn' of undefined
at prepopulate.js:2
at prepopulate.js:39
(anonymous) @ prepopulate.js:2
(anonymous) @ prepopulate.js:39
mywebsite.com/:18 GET https://mywebsite.com/static/admin/js/vendor/xregexp/xregexp.js net::ERR_ABORTED
mywebsite.com/:200 GET https://mywebsite.com/static/admin/js/change_form.js net::ERR_ABORTED
mywebsite.com/:209 GET https://mywebsite.com/static/admin/js/prepopulate_init.js 404 (Not Found)
DateTimeShortcuts.js:277 Uncaught TypeError: django.jQuery is not a function
at Object.addCalendar (DateTimeShortcuts.js:277)
at init (DateTimeShortcuts.js:45)
addCalendar @ DateTimeShortcuts.js:277
init @ DateTimeShortcuts.js:45
/missing-admin-media-prefix/img/icon_calendar.gif:1 GET https://mywebsite.com/missing-admin-media-prefix/img/icon_calendar.gif 404 (Not Found)
Image (async)
HTMLElement.appendChild @ VM155:323
addCalendar @ DateTimeShortcuts.js:224
init @ DateTimeShortcuts.js:45
web服务器是nginx,配置文件:
location /static {
alias /home/django/django_project/django_project/static;
}
# Proxy the static assests for the Django Admin panel
location /static/admin {
alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
}
我还将第二个地址改为:
alias /home/django/django_project/django_project/static/admin;
但仍然不起作用。(我使用数字海洋作为主机)
-
我没有编辑管理模板
-
我用过
collectstatic
生产版本中的命令
-
使用不同的浏览器进行检查
-
django的服务器和本地版本均为1.11
那么我做了之后还要做些别的事情吗
收集静态
?