Well, I'm using a theming system -- each user can choose a theme to use, and that choice is attached to their account. Not just the base template but the inner templates for some parts of the site can vary from theme to theme, so I want to run something to the following effect:
def my_r2r(request, template, context): # template is a path like 'app/foo.html' theme = request.user.get_profile().theme theme_template = theme.adjust_theme_path(template) t = loader.select_template((template, theme_template)) return HttpResponse(t.render(RequestContext(request, context))) A custom template loader would be a really neat solution, but I can't see any way to pass it the request in order for it to select the template. On Oct 12, 3:17 pm, Arthur Metasov <meta...@gmail.com> wrote: > You should carefully look at the code of django template loaders. > What do you mean? Dou you want template paths to be stored in the database > and dinamically change? Or do you want to use 3rd-party app but change > template dirs it is looking for? > > 2009/10/12 ringemup <ringe...@gmail.com> > > > > > I need to find a way to programmatically change the template path for > > every view in my project -- a decorator seems like a nice DRY way to > > accomplish that. But what's the best way to apply it to views in > > third-party apps? > > > The only way to accomplish this that I can think of is to declare new > > decorated versions of the view functions in my own views.py and > > duplicate the urlpatterns into my own urlconf rather than including > > the apps' url patterns. The new patterns will call the decorated > > functions. > > > Is there a cleaner or simpler way to do this? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---