Django debug toolbar giving error about static file location

103 Views Asked by At

For the entire time I've been working on this project, I have had no problems with django debug toolbar, but suddenly, when I have it enabled, it gives me the error: The joined path (/images/user/blank-avatar.png) is located outside of the base path component (/opt/project/projectfiles/static). When DJDT is disabled, I get absolutely no errors.

I'm not sure why this happens. When I go into the shell and check what django.conf.settings.STATIC_ROOT is set to, it comes back with /app/staticfiles, which is correct. I have no idea where this /opt/project/projectfiles/static is coming from. When I do a search through the entire project, there is no place where /opt, or opt/ shows up.

This project is in a docker container, and the project is completely stored in the /app directory. I'm not married to DJDT, since I so rarely use it, but I am concerned that this shows something I might be doing wrong.

Before anyone asks, this is not a media file. It legitimately is in the static folder at /app/projectfiles/static/images/user/blank-avatar.jpg. In production, it is stored on a digitalocean spaces container.

Apparently it is the {{ staticfile.real_path }} section in the following template code that finally raises the error:

  </ol>
{% else %}
  <p>{% trans "None" %}</p>
{% endif %}

<h4>{% blocktrans count staticfiles|length as staticfiles_count %}Static file{% plural %}Static files{% endblocktrans %}</h4>
{% if staticfiles %}
  <dl>
    {% for staticfile in staticfiles %}
      <dt><strong><a class="toggleTemplate" href="{{ staticfile.url }}">{{ staticfile }}</a></strong></dt>
      <dd><samp>{{ staticfile.real_path }}</samp></dd>
    {% endfor %}
  </dl>
{% else %}
  <p>{% trans "None" %}</p>
{% endif %}


{% for finder, payload in staticfiles_finders.items %}
  <h4>{{ finder }} ({% blocktrans count payload|length as payload_count %}{{ payload_count }} file{% plural %}{{ payload_count }} files{% endblocktrans %})</h4>
  <table>
0

There are 0 best solutions below