Opened 5 years ago

Closed 5 years ago

#19410 closed Uncategorized (duplicate)

Proposal: using relative paths in tutorial for less fragile projects

Reported by: kristian.i.kolev@… Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I was going through the Polls tutorial and I noticed that it uses hardcoded absolute paths in the mysite/ 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 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 this issue, perhaps because the mechanism would be too implicit.

I saw a snippet in a Django tips SO thread, something like:

import os
PROJECT_DIR = os.path.abspath(
PROJ_DIR_LAMBDA = lambda filename: os.path.join(PROJECT_DIR, filename)
'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?

Change History (1)

comment:1 Changed 5 years ago by Aymeric Augustin

Resolution: duplicate
Status: newclosed

Duplicate of #16504.

Note: See TracTickets for help on using tickets.
Back to Top