【问题标题】:The joined path is located outside of the base path component连接路径位于基本路径组件之外
【发布时间】:2019-12-03 15:59:59
【问题描述】:

Django 1.9 上有一个项目。我在1.11 上重写了它。但是当我部署到服务器并收集静态时,我得到一个错误

django.core.exceptions.SuspiciousFileOperation:连接路径 (/var/www/vhosts/finbee.freshlimestudio.com/assets/fonts/finbeeFont/fonts/finbeeFont.eot) 位于基本路径组件之外 (/var/www/vhosts/finbee.freshlimestudio.com/static)

所有回溯here:

PROJ_MODULE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
ROOT = os.path.normpath(os.path.join(PROJ_MODULE_ROOT, ".."))
root_path = lambda *args: os.path.join(ROOT, *args)
path = lambda *args: os.path.join(PROJ_MODULE_ROOT, *args)


STATIC_URL = '/static/'
STATIC_ROOT = ''

STATICFILES_DIRS = (
    path('static'),
)

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

【问题讨论】:

    标签: django deployment static collectstatic


    【解决方案1】:

    lambda 函数是否必要?这样的事情应该可以工作。

    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    # BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__), '..'))
    
    STATICFILES_DIRS = [
        os.path.join(BASE_DIR, 'static'),
    ]
    

    【讨论】:

      猜你喜欢
      • 2019-04-14
      • 1970-01-01
      • 2019-07-08
      • 2021-02-01
      • 1970-01-01
      • 2016-02-11
      • 2014-09-07
      • 2022-07-14
      • 2016-09-11
      相关资源
      最近更新 更多