简体   繁体   中英

How to check BASE_DIR in django?

I was running into a lot of file not found for webpack in my static folder, and I later realized that for some reason this particular project (which I'm using docker with) keeps trying to check another project folder's static folder for the files I would want. I'm not sure where this could've gone wrong other than the base_dir, but I never changed that setting. There was a while I was going between the projects and trying to run each one (the other project is basically the same thing but not on docker), was that possibly what's confusing the program? How can I solve it?

BASE_DIR 写在 settings.py 文件中,您可以通过导入来使用它。

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

os.path.join(BASE_DIR,filename)

you can find this code in setting.py file in Django also, you can import that also

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STATIC_ROOT=os.path.join(BASE_DIR,'staticfiles/')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM