简体   繁体   中英

Django debug toolbar wrong paths

I have created a Django app and just deployed it to a server. I use some extra django features such as the django-debug-toolbar which was installed from my requirements.txt file using pip .

When I run my app locally, on localhost, everything works fine and the extra features are loaded successfully.

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. For example, the toolbar.js file is loaded with this command: <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.

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.

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.

The error you received is because those files weren't in the directory your nginx was looking in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM