【发布时间】:2021-11-26 12:08:43
【问题描述】:
我希望我的 STATIC_ROOT 路径位于 F:/7.Django/BLOG_PROJECT/src_blog/' + '/vol/web/staticfiles 但 django 将其设置为 F:/vol/web/staticfiles
我这样设置我的 STATIC_ROOT
STATIC_ROOT = os.path.join(BASE_DIR,'/vol/web/staticfiles')
print('this is base_dir')
print(BASE_DIR)
print("this is static_root")
print(STATIC_ROOT)
当我运行 python manage.py runserver 时,它会打印出来:
this is base_dir
F:\7.Django\BLOG_PROJECT\src_blog
this is static_root
F:/vol/web/staticfiles
this is base_dir
F:\7.Django\BLOG_PROJECT\src_blog
this is static_root
F:/vol/web/staticfiles
当我运行python manage.py collectstatic。当然!它将我的 STATIC_ROOT 设置为F:/vol/web/staticfiles。我注意到它打印出单独的文件夹符号不同的'/'和#backslashsymbol。顺便说一句,我使用 Windows 操作系统。
【问题讨论】:
-
您遇到的具体错误是什么?
-
没有任何错误。它只是将 Static_root 路径设置在我想要的位置
-
那么与当前输出相比,期望的结果是什么?
-
我想要的文件路径
F:/7.Django/BLOG_PROJECT/src_blog/vol/web/staticfiles
以及我当前的Static_root路径F:/vol/web/staticfiles -
您可以尝试先将两个路径作为字符串连接,然后再将其转换回路径对象。您可能应该将
/更改为\\以保持一致
标签: python django static django-staticfiles django-3.2