Hi,
On Saturday 22 December 2012, Florian Apolloner wrote:
> On Saturday, December 22, 2012 10:35:59 PM UTC+1, Ben Porter wrote:
> > I would like to see support for relative paths. It seems the solution is
> > simple, but I wonder if there is some compelling reason to require
> > absolute paths?
>
> It would seem so but it is everything but simple: First of, for a relative
> path one needs a base path to join with, what is that? In your example it's
> the project root, Django doesn't have such thing as a project root.
You are right, but that might be the root of the problem (no pun intended).
Django doesn't have a concept of a project root, and (partly as a result)
requires paths to almost anything that isn't a python module to be given as
absolute path.
I think adding an optional "PROJECT_ROOT" or "PROJECT_PATH_BASE" setting,
specifying that other paths can be made relative to it, will remove a
significant amount of boilerplate in settings files, and will not have any of
the problems you name.
Personally, I have yet to see a settings file in a non-trivial Django project
that doesn't do the os.path.join(os.path.dir(__file__), ...) dance. When done
properly, you end up with a function in_proj_dir that is applied to many
settings values. It would be much cleaner, IMO, to have this code defined in
the framework (rather than settings files) and limit the use of code to a
single setting.
My 2 cents,
Shai.
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.