Here's my two cents. Hope it helps some.

from proj.settings import TEMPLATE_DIRS, INSTALLED_APPS
import os

def recursive_search(path):
   result = []
   for i in os.listdir(path):
      if not os.path.isdir(os.path.join(path, i)):
         result.append(i)
       else:
         result.extend(recursive_search(os.path.join(path, i)))
   return result

def myview(request):
    templates = []
    # the next 2 lines handles templates in explicit template
directories
    for path in TEMPLATE_DIRS:
       templates.extend(recursive_search(path))
    # the next 2 will handle template dir generated py the
appdirectories loader excluding contrib apps
    for app in INSTALLED_APPS:
        if app.startswith('proj'):
             if os.path.exists(os.path.join(ABSPATH_TO_PROJ,
app.split('.')[-1], 'templates')):
 
templates.extend(recursive_search(os.path.join(ABSPATH_TO_PROJ,
app.split('.')[-1], 'templates')))

 well, you have a list of templates with which you can do as you
please. surely you'll want to keep track of the actual path django
uses to locate these templates, you can do so by tweaking the
recursive_search funct a little



On Feb 11, 2:34 am, Patrick Wellever <pwelle...@gmail.com> wrote:
> Thanks for the reply. Yes, this wouldn't be too tough if the directories in 
> TEMPLATE_DIRS were all I had to worry about, but the glitch I mentioned 
> earlier is that Django can also look for templates in places other than those 
> listed explicitly in that setting.
>
> For example, the template loader 
> 'django.template.loaders.app_directories.Loader', which is enabled by 
> default, looks for a "templates" directory within each one of your "installed 
> apps." So a solution that only considers paths in TEMPLATE_DIRS would not 
> work in that situation.
>
> - Patrick
>
>
>
>
>
>
>
> On Friday, February 10, 2012 at 5:05 PM, Bill Beal wrote:
> > I know nothing, but here's what I did:
>
> > python manage.py shell
> > import os
> > from settings import TEMPLATE_DIRS
> > for x in TEMPLATE_DIRS:
> >   print x
> >   os.listdir(x)
>
> > It gave me a list of the files in the (each) template directory.
>
> > It looks like you already have a list of template directories in 
> > settings.py.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to