﻿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
19410	Proposal: using relative paths in tutorial for less fragile projects	kristian.i.kolev@…	nobody	"I was going through the [[http://stackoverflow.com/questions/550632/favorite-django-tips-features|Polls tutorial]] and I noticed that it uses hardcoded absolute paths in the mysite/settings.py file, for example in NAME (sqlite3 database) and TEMPLATE_DIR.

I feel uneasy about using absolute paths in this case, because I need to fix settings.py every time I move the project to a different path (e.g. checking it out from a repo to a new box). I searched around for relative path support and saw that the core devs were against it in [[https://code.djangoproject.com/ticket/694|this issue]], perhaps because the mechanism would be too implicit.

I saw a snippet in [[http://stackoverflow.com/questions/550632/favorite-django-tips-features/550644#550644|a Django tips SO thread]], something like:

{{{#!python
import os
PROJECT_DIR = os.path.abspath(
                os.path.join(
                  os.path.dirname(__file__),
                  '..'
                )
              )
PROJ_DIR_LAMBDA = lambda filename: os.path.join(PROJECT_DIR, filename)
}}}

{{{#!python
'NAME': PROJ_DIR_LAMBDA('sqlite3.db'),
}}}


Would it make sense to add this to the tutorial (even if just as a side note) to encourage best practices from the start?"	Uncategorized	closed	Documentation	1.4	Normal	duplicate			Unreviewed	0	0	0	0	0	0
