Opened 16 years ago
Closed 16 years ago
#7424 closed (wontfix)
Near mentions of TEMPLATE_DIRS absolute path, include tip dynamic absolute path
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | path template absolute | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Most documentation of settings.TEMPLATE_DIRS instructs the user to use absolute paths, in the form of a hardcoded string literal absolute path.
A new user would immediately wonder if they needed to plan their deployment absolute path right then and there.
To avoid this surprise, it would be helpful to note that the absolute path can be created dynamically, such as with:
TEMPLATE_DIRS = (os.path.join(os.path.abspath(os.path.dirname(__file__)), 'templates'),)
Change History (2)
comment:1 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Listing everything you might do in this setting (which is the road this is heading down) isn't really efficient or useful. Also, re-using a settings file without changes in multiple environments isn't necessarily a design goal -- settings will always, at least to some extent, be specific to the environment in which Django is being deployed.
+1 from me. The absolute path is useful in other places as well (DATABASE_NAME for sqlite and MEDIA_ROOT), so I personally always put
{{
import os
PROJDIR = os.path.dirname(os.path.abspath(file))
}}
into
settings.py
and use PROJDIR where absolute path is required.Marking as accepted as projects can not be really used in different environments without this.