【问题标题】:Exception Value: _getfullpathname: path should be string, bytes or os.PathLike, not list异常值:_getfullpathname:路径应该是字符串、字节或 os.PathLike,而不是列表
【发布时间】:2021-06-14 13:50:08
【问题描述】:

我不知道是什么问题,我什么都试了还是不明白,这种情况应该怎么办,请看一下

Setting.py 当我这样做时:


    STATIC_URL = '/static/'
    STATICFILES_DIRS = os.path.join(BASE_DIR, 'static')
    
    MEDIA_URL ='/images/'
    MEDIA_ROOT =  os.path.join(BASE_DIR, 'static/images')

显示这个错误


    ERRORS:
    ?: (staticfiles.E001) The STATICFILES_DIRS setting is not a tuple or list.
            HINT: Perhaps you forgot a trailing comma?

Setting.py 当我这样做时:


    STATIC_URL = '/static/'
    STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]
    
    MEDIA_URL ='/images/'
    MEDIA_ROOT =  [os.path.join(BASE_DIR, 'static/images'),]

显示这个错误


    TypeError: _getfullpathname: path should be string, bytes or os.PathLike, not list
    [17/Mar/2021 13:27:59] "POST /admin/admission/personal/add/ HTTP/1.1" 500 211689

谁能帮忙??

【问题讨论】:

    标签: python-3.x django django-models django-settings


    【解决方案1】:

    试试

    STATIC_URL = '/static/'
    #STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]
    
    MEDIA_URL ='/images/'
    MEDIA_ROOT =  [os.path.join(BASE_DIR, '*yourappname*/static/images'),]
    

    【讨论】:

      【解决方案2】:
      MEDIA_URL ='/images/'
      MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images/')
      

      区别仅在于images末尾的/,即images/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-08-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-04
        • 2020-03-25
        相关资源
        最近更新 更多