当我尝试在Django中运行makemigrations命令时,它给了我一个错误

时间:2019-10-09 07:34:52

标签: django migration settings makemigrations

当我尝试在Django中运行makemigrations命令时,它给了我一个错误:

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

帮助我解决此问题。

这是我的静态根,而媒体根所有东西:

# settings.py
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = [os.path.join(BASE_DIR, 'static_root')]
MEDIA_ROOT = [os.path.join(BASE_DIR, 'media_root')]

1 个答案:

答案 0 :(得分:0)

STATIC_ROOTMEDIA_ROOT不应该是列表,这就是Django抱怨的原因。您应该这样定义它们:

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media_root')

您可以检查herehere