解决 django.core.exceptions.SuspiciousFileOperation 异常

解决 django.core.exceptions.SuspiciousFileOperation 异常


使用 Python 的 django 框架时,可能会出现静态文件加载异常,且错误为:django.core.exceptions.SuspiciousFileOperation: The joined path is located outside of the base path component.

解决方案:

在设置文件中的静态文件路径中,将

os.path.join(BASE_DIR, 'portfolio/static/')

更改为:

os.path.join(BASE_DIR, 'portfolio/static')

即去掉最后的 /


参考链接:django.core.exceptions.SuspiciousFileOperation: The joined path is located outside of the base path component

你可能感兴趣的:(Python)