I am writing a unit test that needs to access an image file that I put in \"fixtures\" directory right under my django app directory. I want to open up this image file in my tes
În newer versions of Django (I don't know when it started, I assume it's there for many years now), the default settingy.py contains an entry
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
which you can use by importing the settings file like this
import os
from my_project_name.settings import BASE_DIR
os.path.join(BASE_DIR, ...)