How to check BASE_DIR in django?

Viewed 875

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?

3 Answers

BASE_DIR is written in settings.py file you can use that by importing it.

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/')

Related