Django: Ticket #18858: add ROOT_PATH to settings.py templatehttps://code.djangoproject.com/ticket/18858
<p>
Hi,
</p>
<p>
Looks like everybody always add this on top of their settings.py (me too) :
</p>
<pre class="wiki">import os
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
</pre><p>
I'm wondering why this couldnt be present in the project_template settings.py
</p>
<p>
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.
</p>
en-usDjangohttps://www.djangoproject.com/s/img/site/hdr_logo.gifhttps://code.djangoproject.com/ticket/18858
Trac 1.2ke1gFri, 07 Sep 2012 23:00:12 GMTeasy, stage changed; cc sethttps://code.djangoproject.com/ticket/18858#comment:1
https://code.djangoproject.com/ticket/18858#comment:1
<ul>
<li><strong>cc</strong>
<em>ke1g</em> added
</li>
<li><strong>easy</strong>
set
</li>
<li><strong>stage</strong>
changed from <em>Unreviewed</em> to <em>Design decision needed</em>
</li>
</ul>
<p>
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.
</p>
<p>
I've certainly seen the lower directory used as ROOT_PATH, and that works too.
</p>
<p>
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.
</p>
<p>
I would make use of it if it were there.
</p>
<p>
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.)
</p>
<p>
It doesn't seem like a major problem either way, so I expect high core team work load to leave it as is.
</p>
TicketJulien PhalipSun, 25 Nov 2012 14:12:29 GMThttps://code.djangoproject.com/ticket/18858#comment:2
https://code.djangoproject.com/ticket/18858#comment:2
<p>
This was wontfixed in <a class="closed ticket" href="https://code.djangoproject.com/ticket/16504" title="#16504: New feature: PROJECT_ROOT ought to be in the generated project settings module (closed: wontfix)">#16504</a>. However, I've heard this request multiple times during <a class="wiki" href="https://code.djangoproject.com/wiki/DjangoCon">DjangoCon</a> (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 <code>__file__</code> trick, but I think something should be done to help beginners.
</p>
TicketTim GrahamSun, 10 Feb 2013 18:18:42 GMTstatus, stage changed; resolution sethttps://code.djangoproject.com/ticket/18858#comment:3
https://code.djangoproject.com/ticket/18858#comment:3
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
<li><strong>stage</strong>
changed from <em>Design decision needed</em> to <em>Accepted</em>
</li>
</ul>
<p>
BASE_DIR was added in <a class="changeset" href="https://code.djangoproject.com/changeset/3f1c7b70537330435e2ec2fca9550f7b7fa4372e/" title="Simplified default project template.
Squashed commit of:
commit ...">3f1c7b70537330435e2ec2fca9550f7b7fa4372e</a>
</p>
TicketJulien BouquillonMon, 11 Feb 2013 08:24:30 GMThttps://code.djangoproject.com/ticket/18858#comment:4
https://code.djangoproject.com/ticket/18858#comment:4
<p>
héhé very good news :)
</p>
Ticket