python - Django调试工具栏1.8离线模式

标签 python jquery django offline django-debug-toolbar

我开始在 django 1.11.17 的项目中使用 django 调试工具栏 1.8,一切都很顺利,直到我尝试在没有互联网的家里使用它(根本不显示),这是唯一的区别我能想到。有什么想法吗?

最佳答案

这是我发现的,django 调试工具栏 1.8 仍然依赖于 jquery,并试图从 ajax.googleapis.com 获取它,所以这就是问题所在。

阅读 https://django-debug-toolbar.readthedocs.io/en/latest/changes.html#id19 上的文档我了解到,从 django 调试工具栏 1.2 开始,jquery 不再捆绑在代码上

1.2 (2014-04-25)

New features

The JQUERY_URL setting defines where the toolbar loads jQuery from.

代码中的当前值:

'JQUERY_URL': '//ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js'

解决方案:

  1. Download a copy of jquery and serve it locally

下载内容 https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js并保存 它位于名为 jquery-2.2.4.min.js 的文件中。在中打开一个终端 文件所在的文件夹并运行:

对于 python 2.x

python -m SimpleHTTPServer 2000

对于 python 3.x

python -m http.server 2000
  1. Configure your project to work offline

将其放在 settings.py 中

DEBUG_TOOLBAR_CONFIG = {
 'JQUERY_URL': '//localhost:2000/jquery-2.2.4.min.js'
}

只需运行您的服务器并开始调试!

关于python - Django调试工具栏1.8离线模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54099628/

相关文章:

python - DeepLab tensorflow : TypeError: MonitoredTrainingSession() got an unexpected keyword argument 'summary_dir'

python - 在对数对数刻度上使用 matplotlib 拟合曲线

python - Selenium 远程连接拒绝使用 Python split

php - Ajax/jQuery 和 PHP 函数

javascript - jquery 变量不起作用

python - 获取 Pandas 中两行之间的差异

jquery - 在 jQuery 集合上运行 reduce()

jquery - 使用ajax删除Django db中的记录

python - 使用 Django REST Framework ViewSets 表示多个对象/列表 CRUD 操作

javascript - 如何从 Javascript 将 Json 保存到 django 数据库中