Since the day I started using Django, I have always used a relative path
for TEMPLATES_DIR.

import os
CURRENT_DIR = os.path.realpath(os.path.dirname(__file__))
TEMPLATE_DIRS  =  "%s/templates/" % ( CURRENT_DIR, )

Imho, the idea of having to hard code your PROJECT_ROOT is ludicrous.

I understand the arguments being made about relative paths on settings, but
I am yet to come across a project where the above code has not worked.

Could we not have something like this in the settings.py, which in turn
enabled the code pasted above?
TEMPLATE_PATH_RELATIVE=True

Cal

On Sat, Dec 29, 2012 at 2:07 AM, Luke Plant <[email protected]> wrote:

>
>
> On 28/12/12 16:42, Daniel Sokolowski wrote:
> > PROJECT_ROOT is what I have been using myself and seen it done by others
> > so to me it makes sense to introduce an official setting for this
> purpose.
>
> PROJECT_ROOT would still need to be defined inside the settings.py
> module, using the os.path.dir(__file__) etc. dance, because it can't be
> defined within django code (which doesn't know where your project
> lives), and a utility function to do it isn't worth it (it's only one
> line, and you don't want your settings file to be doing imports to
> Django code).
>
> So I agree with the original WONTFIX here.
>
> I also think that app directories for the template loader is a better
> solution, and making a 'project' app if necessary answers the objection.
>
> However, I do see a case for putting the PROJECT_ROOT code into the
> settings.py generated by creating a new template, and updating the help
> text for TEMPLATE_DIRS and STATICFILES_DIRS to mention it.
>
>
> Luke
>
>
> --
> The fashion wears out more apparel than the man.
>             -- William Shakespeare
>
> Luke Plant || http://lukeplant.me.uk/
>
> --
> 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.
>
>

-- 
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.

Reply via email to