On Tue, Jun 30, 2009 at 7:54 AM, KLEIN Stéphane <[email protected]>wrote:

>
> Sorry, I've some break line issue in my previous post.
> This is my post cleaned.
>
> Hi,
>
> When I configuration my TEMPLATE_DIRS in settings.py file, I use ever
> "here" or "here_cross" lambda function defined like this :
>
> ::
>
>    import os
>    here = lambda x: os.path.join(os.path.abspath(os.path.dirname
> (__file__)), x)
>    here_cross = lambda x: os.path.join(os.path.abspath(os.path.dirname
> (__file__)), *x)
>
> I can configure TEMPLATE_DIRS or MEDIA_ROOT like this :
>
> ::
>
>    MEDIA_ROOT = ''
>
>
>    TEMPLATE_DIRS = (
>        # Put strings here, like "/home/html/django_templates" or "C:/
> www/django/templates".
>        # Always use forward slashes, even on Windows.
>        # Don't forget to use absolute paths, not relative paths.
>        here('myapp/templates'),
>        here_cross(('otherapp', 'templates')),
>    )
>
> I suppose that this comment "Don't forget to use absolute paths, not
> relative paths" is relevant if I don't use "here" or "here_cross"
> function. If I don't use it, template paths are relative to current
> working directory and not to "settings.py" file.
>
> What do you think about this methode (using here) ?
> Why don't put "here" or/and "here_cross" in Django settings.py
> skeleton ?
>
> Note, I found here and here_cross tip on this page :
> http://www.djangosnippets.org/snippets/445/
>

If it works for you, it works. Personally I find lambdas a little difficult
to read, and personally in this situation, I just put:
os.path.normpath(os.path.join(os.path.dirname(__file__), 'otherapp',
'templates'))

inside of TEMPLATE_DIRS directly. I find that clearer to see what is
happening, it is all in one line and still really simple.

But what works for you works for you.

Michael

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to