[Django]-BASE_DIR returning settings path and not project path (django 1.10)

7👍

Try one more dirname call

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

The first dirname gives you settings, the second gives you the config folder, the third will put you in the parent directory

__file__ # is the current file location
os.path.abspath(__file__) # locates you on the file structure
os.path.dirname(os.path.abspath(__file__)) # gives you the directory of the file at the supplied filepath

The default assumption is you are using a settings.py file rather than a directory, so you are one directory shallow in the original config

Leave a comment