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.