[英]Django debug toolbar wrong paths
I have created a Django app and just deployed it to a server. 我创建了一个Django应用,并将其部署到服务器上。 I use some extra django features such as the django-debug-toolbar which was installed from my requirements.txt file using pip
. 我使用了一些额外的django功能,例如django-debug-toolbar,该功能是使用pip
从我的requirements.txt文件中安装的。
When I run my app locally, on localhost, everything works fine and the extra features are loaded successfully. 当我在localhost上本地运行应用程序时,一切正常,并且额外功能已成功加载。
Here is the right structure of the sources loaded: 这是加载的源的正确结构:
But when I run my app from the server for some reason the paths are not correct. 但是当我出于某种原因从服务器运行我的应用程序时,路径不正确。
And in my browser's console I get these errors: 在浏览器的控制台中,我得到以下错误:
All these paths are from the installed packages like the django-debug-toolbar and it wouldn't make sense to change them. 所有这些路径都来自已安装的软件包,例如django-debug-toolbar,更改它们没有任何意义。 For example, the toolbar.js
file is loaded with this command: <script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
例如,使用以下命令加载toolbar.js
文件: <script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
which can be found in the: lib/python2.7/site-packages/debug_toolbar/templates/debug_toolbar/base.html
file, which was created after I installed all the packages from my requirements.txt file. 可以在以下位置找到该文件: lib/python2.7/site-packages/debug_toolbar/templates/debug_toolbar/base.html
文件,该文件是在我从requirements.txt文件安装了所有软件包之后创建的。
That should work fine. 那应该工作正常。 It does work fine when I run it locally, but it doesn't when I run on the new server. 当我在本地运行它时,它运行正常,但是当我在新服务器上运行时,它却无法运行。 Any ideas? 有任何想法吗?
As mentioned in the comments, you need to call collectstatic
when you make changes to the static files. 如注释中所述,对静态文件进行更改时需要调用collectstatic
。
What this command does is copy the static files from their static
folders to the location that you specify in your STATIC_ROOT
directory, this should be the same as where nginx is looking for files. 该命令的作用是将静态文件从其static
文件夹复制到您在STATIC_ROOT
目录中指定的位置,该位置应与nginx在查找文件的位置相同。
The error you received is because those files weren't in the directory your nginx was looking in. 您收到的错误是因为这些文件不在您的nginx查找目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.