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
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
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
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
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
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
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):
7 matches
Mail list logo