Rendered output from a template tag

2009-06-25 Thread Daniele Procida
I created a simple_tag: def news_for_this_page(page): if page.entity_set.all(): # check page belongs to an entity first e = page.entity_set.all()[0] # first entity will be only one newslist = [] for item in e.newsitem_set.all(): # get entity's news items ne

Re: Rendered output from a template tag

2009-06-25 Thread Michael
On Thu, Jun 25, 2009 at 1:52 PM, Daniele Procida wrote: > > I created a simple_tag: > > def news_for_this_page(page): >if page.entity_set.all(): # check page belongs to an entity first >e = page.entity_set.all()[0] # first entity will be only one >newslist = [] >for ite

Re: Rendered output from a template tag

2009-06-25 Thread Daniel Roseman
On Jun 25, 6:52 pm, "Daniele Procida" wrote: > I created a simple_tag: > > def news_for_this_page(page): >     if page.entity_set.all(): # check page belongs to an entity first >         e = page.entity_set.all()[0] # first entity will be only one >         newslist = [] >         for item in e.n

Re: Rendered output from a template tag

2009-06-25 Thread Daniele Procida
On Thu, Jun 25, 2009, Daniel Roseman wrote: >> To do this, I think I need my function to call another template to >> render it appropriately - is that correct? >The best thing to do here is to use an 'inclusion tag' Thanks, I'm looking at that now, because the solution I came up with is also i

Re: Rendered output from a template tag

2009-06-26 Thread Brian May
On Thu, Jun 25, 2009 at 02:03:16PM -0400, Michael wrote: > Inclusion tags might help you out with the template idea, but generally for > variables like this I like to put them in context like this: > http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#setting-a-variable-in-the-context

Re: Rendered output from a template tag

2009-06-26 Thread Michael
On Fri, Jun 26, 2009 at 5:17 AM, Brian May wrote: > > On Thu, Jun 25, 2009 at 02:03:16PM -0400, Michael wrote: > > Inclusion tags might help you out with the template idea, but generally > for > > variables like this I like to put them in context like this: > > > http://docs.djangoproject.com/en/d

Re: Rendered output from a template tag

2009-06-26 Thread Daniele Procida
On Fri, Jun 26, 2009, Brian May wrote: >Is it possible to do the same thing with register.simple_tag, and maybe >takes_context (assuming register.simple_tag supports that)? What I used in the end was: @register.inclusion_tag('newslist.html', takes_context=True) def news_for_this_page(context):