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
            newslist.append(item.headline) # add them to the list       
        return newslist
    else:
        return "No news is good news"

What this spits back into the page is: 

    [u'Man bites dog', u'Dog bites man', u'Nixon resigns']

so obviously I need to process that list, making it a <ul> and putting
in the links before sending that to the template.

To do this, I think I need my function to call another template to
render it appropriately - is that correct?

Are there any shortcuts in this process? 

For example, to use my template tag I use {% news_for_this_page entity
%}. It would be neater to use something like {% news_for_this_page %},
since entity will always be set.

Thanks,

Daniele


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

Reply via email to