加载中...

TypeError: _getfullpathname: path should be string, bytes or os.PathLike, not tuple

问题

TypeError: _getfullpathname: path should be string, bytes or os.PathLike, not tuple

在settings.py文件中,MEDIA_ROOT和STATIC_ROOT 变量的值都以逗号结尾,而 逗号会将这些变量的值从字符串转换为元组。

MEDIA_ROOT = os.path.join(BASE_DIR, 'media'),  # This is a tuple
STATIC_ROOT = os.path.join(BASE_DIR, 'static'),  # So is this

解决方案:
删除结尾的 逗号,就能解决

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')  # This is now a string
STATIC_ROOT = os.path.join(BASE_DIR, 'static')  # So is this

弄了半天才发现是这个问题,感觉都快急死了
谢谢这个大哥的答案
https://blog.csdn.net/bjtusjl/article/details/108218430

posted @ 2022-06-24 18:42  最大的敌人是自律  阅读(589)  评论(0)    收藏  举报