Alan, I think what you're talking about is this paragraph from the doc: "Also, you can give RequestContext a list of additional processors, using the optional, third positional argument, processors. In this example, the RequestContext instance gets a ip_address variable:
def ip_address_processor(request): return {'ip_address': request.META['REMOTE_ADDR']} def some_view(request): # ... return RequestContext(request, { 'foo': 'bar', }, [ip_address_processor]) " This isn't what I want, because it still forces me to explicitly write something in every single view function, for every single variable, that I ever want to appear in any included templates. That sounds like a maintenace nightmare. What I want is a way for an included template to have its _own_ view function and load its own objects. And I want the containing template to know nothing of the variables the included template uses. Mae Alan Green wrote: > Hi Mae, > > Two thoughts here: > > 1. Have a look at the TemplateContextProcessors: > http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext > > 2. Custom tags aren't that hard to write. > > Alan. > > On 8/25/06, Mae <[EMAIL PROTECTED]> wrote: > > > > Hi all, here's my problem: > > I have a bunch of templates that look like this: > > > > base.html: > > {% block ticker %} > > { % include "ticker.html" % } > > {% endblock %} > > > > content_page1.html: > > {% extends "base.html" %} > > do other stuff... > > > > content_page2.html: > > {% extends "base.html" %} > > do completely other stuff... > > > > > > I want the ticker.html template to use a Ticker object. I could load > > the ticker object in the views for content_page1 and content_page2, and > > then pass Ticker to ticker.html. But that's messy. What if I have 40 > > content pages? I'd have to pass Ticker in 40 different view methods! > > And I don't want the content pages to have to know how ticker.html > > works, they should just include it, and delegate the details of its > > operation to it. > > > > So what I need, is to do something like > > { % include "ticker" % } > > where "ticker" is registered in urls.py as its own view, loading its > > own set of objects. > > > > Can I do this? I've read the templates doc page, and found no > > suggestions. Except maybe to use a custom tag, but I'd like to be able > > to do this for a bunch of objects, casually, and I don't want to have > > to write a custom tag for every occasion. > > > > I've checked out this > > http://groups.google.com/group/django-users/browse_thread/thread/1fbc16605cdb43b/819c3bbf9a52c375?lnk=st&q=included+template+object+django&rnum=3&hl=en#819c3bbf9a52c375 > > post about inclusion tags, and it's not exactly what I want. As far as > > I can tell, inclusion tags would allow me to load an object in the > > parent template, and then pass it to the included template. But I want > > the included template to be responsible for loading their own objects. > > > > Any ideas? > > Thanks, > > Mae > > > > > > > > > > > > -- > Alan Green > [EMAIL PROTECTED] - http://bright-green.com --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---