Opened 20 months ago

Closed 14 months ago

Last modified 14 months ago

#18858 closed Cleanup/optimization (fixed)

add ROOT_PATH to template

Reported by: revolunet Owned by: nobody
Component: Core (Management commands) Version: 1.4
Severity: Normal Keywords:
Cc: ke1g Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no



Looks like everybody always add this on top of their (me too) :

import os
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))

I'm wondering why this couldnt be present in the project_template

I know this is not a real 'setting', rather python code, but adding this would simplify things a bit for beginners and prevent hard coded paths which are usually a bad practice.

Attachments (0)

Change History (4)

comment:1 Changed 20 months ago by ke1g

  • Cc ke1g added
  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

Not everyone wants that directory as ROOT_PATH. With the new directory layout in 1.4, I find myself wanting one directory up as ROOT_PATH. I put thingss like static, media, and the source directory for non-app-related static in sub-directories there, rather than under the directory containing, etc. So far that has worked just fine for me.

I've certainly seen the lower directory used as ROOT_PATH, and that works too.

Yes, we could have one or the other by default, and those of us with the opposite opinion could edit it. Folks who really didn't want either could comment it out.

I would make use of it if it were there.

HOWEVER, I wonder whether it represents an extra confusion for newbies. The file is complex enough already. (And stuff heard at Djangocon2012 suggests that it may soon be changing significantly.)

It doesn't seem like a major problem either way, so I expect high core team work load to leave it as is.

comment:2 Changed 17 months ago by julien

This was wontfixed in #16504. However, I've heard this request multiple times during DjangoCon (Toulouse chapter, 2012). Apparently a lot of beginners get tripped up by the configuration of absolute paths in the settings (for the templates, static files, etc.). I'm not sure if this should be fixed with some documentation, or with some comments in the default project file, or by directly using the __file__ trick, but I think something should be done to help beginners.

comment:3 Changed 14 months ago by timo

  • Resolution set to fixed
  • Status changed from new to closed
  • Triage Stage changed from Design decision needed to Accepted

comment:4 Changed 14 months ago by revolunet

héhé very good news :)

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.