﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23436	Should use abspath for default settings.BASE_DIR	Harry Percival	nobody	"ref the default project template's settings.py, BASE_DIR is defined as:

{{{
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
}}}

Because there's no abspath, you can get different results for BASE_DIR depending on how settings.py is run.  This is an edge case, since settings.py is almost always imported by django in the right context, but still -- compare:

{{{
    python manage.py shell
    >>> from django.conf import settings
    print(BASE_DIR)
}}}

With:

{{{
    python -i myproject/settings.py
    >>> print(BASE_DIR)
}}}

As an aside, in general, in any path wrangling you should always call abspath first. Try running this script, saved to a file:

    import os
    print(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
    print(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

As to tests, the only one I can think of would be a pretty horrible one involving actually callling out using subprocess.Popen to a python -i of the project template settings file, so maybe ok not to bother?

credit to @CleanCut for turning me onto this weirdness!"	Cleanup/optimization	new	Uncategorized	1.6	Normal				Unreviewed	0	0	0	0	0	0
