djangodeploymentstaticcollectstatic

The joined path is located outside of the base path component


There was a project on Django 1.9. I rewrote it on 1.11. But when I deploy to the server and collectstatic, I get an error

django.core.exceptions.SuspiciousFileOperation: The joined path (/var/www/vhosts/finbee.freshlimestudio.com/assets/fonts/finbeeFont/fonts/finbeeFont.eot) is located outside of the base path component (/var/www/vhosts/finbee.freshlimestudio.com/static)

All traceback 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',
)

Solution

  • Are the lambda functions necessary? Something like this should work.

    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'),
    ]