Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#18858 closed Cleanup/optimization (fixed)

add ROOT_PATH to settings.py 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

Description

Hi,

Looks like everybody always add this on top of their settings.py (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 settings.py

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 by ke1g, 12 years ago

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 settings.py, 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 settings.py 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 by Julien Phalip, 12 years ago

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 settings.py file, or by directly using the __file__ trick, but I think something should be done to help beginners.

comment:3 by Tim Graham, 12 years ago

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

comment:4 by Julien Bouquillon, 12 years ago

héhé very good news :)

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