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


i'm using django 10 , dont know why after collect static files successfuly, when try run server in deployment mode(debug=false) occurs me this:

when static file doing: python manage.py findstatic /static/mysite/js/javascript.js

django.core.exceptions.suspiciousfileoperation: joined path (/static/mysite/js/javascript.js) located outside of base path component (/home/xxxx/.venvs/mysite/local/lib/python2.7/site-packages/django/contrib/admin/static)

i run using virtual env 'mysite'.

in settings.py:

static_url = '/static/'  static_root = os.path.join(base_dir, "static") (i tried 'static')  media_root = base_dir + '/mysite/media'  media_url = '/media/' 

my urls.py:

urlpatterns = [        url(r'', include('mysite.urls')), ]  urlpatterns += staticfiles_urlpatterns() 

this new me, did django website , never occurs such error. why not considering static_root path? other hand collectstatic works fine. , if runserver debug true works charm.

findstatic’s positional argument parameter pass static render particular static file in template. error seeing because used absolute path , not parameter pass static function in template. sure didn’t mean like:

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

for file refer

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

or

python manage.py findstatic js/javascript.js 

for file refer with

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

for reference:

usage: manage.py findstatic [-h] [--version] [-v {0,1,2,3}]                             [--settings settings] [--pythonpath pythonpath]                             [--traceback] [--no-color] [--first]                             staticfile [staticfile ...]  finds absolute paths given static file(s).  positional arguments:   staticfile 

n.b., django's staticfiles app not supposed used in production. in production, supposed use webserver serve static files based. e.g., nginx, include a block this:

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

to debug static files check static_root directory after run collectstatic , make sure files there. if are, make sure webserver configured serve static files directory.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -