Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#18858 closed Cleanup/optimization (fixed)

add ROOT_PATH to template

Reported by: Julien Bouquillon 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.

Change History (4)

comment:1 Changed 6 years ago by ke1g

Cc: ke1g added
Easy pickings: set
Triage Stage: UnreviewedDesign 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 5 years ago by Julien Phalip

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 5 years ago by Tim Graham

Resolution: fixed
Status: newclosed
Triage Stage: Design decision neededAccepted

comment:4 Changed 5 years ago by Julien Bouquillon

héhé very good news :)

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