Code

Opened 6 years ago

Closed 6 years ago

#7424 closed (wontfix)

Near mentions of TEMPLATE_DIRS absolute path, include tip dynamic absolute path

Reported by: Jeff Kowalczyk <jtk@…> Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: path template absolute
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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'),)

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by mrts

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

+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.

comment:2 Changed 6 years ago by ubernostrum

  • Resolution set to wontfix
  • Status changed from new to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.