# first example import os here = lambda x: os.path.join(os.path.abspath(os.path.dirname(__file__)), x) # usage MEDIA_ROOT = here('media') # second example, cross platform import os here_cross = lambda x: os.path.join(os.path.abspath(os.path.dirname(__file__)), *x) # usage MEDIA_ROOT = here_cross(('files','media'))