我不知道是什么问题,我尝试了一切,但从来没有理解,我应该怎么做,在这种情况下,请看看
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
有谁能帮忙吗?
3条答案
按热度按时间bmvo0sr51#
尝试
ev7lccsx2#
差仅为
images
的末尾处的/
,即images/
。cvxl0en23#
在我的情况下,我删除了这个[]括号,它为我工作!
问题:MEDIA_ROOT = [os.path.join(BASE_DIR,'media')]
为我解答:os.path.join(BASE_DIR,'media')
只需删除[]括号