【问题标题】:When i try to run makemigrations command in django it gave me an error当我尝试在 django 中运行 makemigrations 命令时,它给了我一个错误
【发布时间】:2019-10-09 07:34:52
【问题描述】:

当我尝试在 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')]

【问题讨论】:

    标签: django migration settings makemigrations


    【解决方案1】:

    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

    【讨论】:

    • 当更多时,我在哪里可以检查迁移的模型数据。像 xampp 之类的 GUI 工具或任何在 cmd 或任何其他中显示模型的命令。
    猜你喜欢
    • 2018-12-12
    • 2020-02-28
    • 2019-09-22
    • 2014-11-11
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多