Django: The joined path is located outside of the base path component

喜欢而已 提交于 2019-12-05 19:33:44

findstatic’s positional argument is the parameter you would pass to static to render a particular static file in a template. The error you are seeing is because you used an absolute path and not the parameter you would pass to the static function in a template. Are you sure you didn’t mean something like:

python manage.py findstatic mysite/js/javascript.js

for a file you would refer to with

{% static 'mysite/js/javascript.js' %}

or

python manage.py findstatic js/javascript.js

for a file you would refer to with

{% static 'js/javascript.js' %}

For your reference:

usage: manage.py findstatic [-h] [--version] [-v {0,1,2,3}]
                            [--settings SETTINGS] [--pythonpath PYTHONPATH]
                            [--traceback] [--no-color] [--first]
                            staticfile [staticfile ...]

Finds the absolute paths for the given static file(s).

positional arguments:   staticfile

n.b., django's staticfiles app is not supposed to be used in production. In production, you are supposed to use a webserver to serve static files based. e.g., for nginx, you would include a block like this:

location /static {
    root /path/to/django;
}

To debug your static files check your STATIC_ROOT directory after you run collectstatic and make sure your files are there. If they are, make sure your webserver is configured to properly serve your static files directory.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!