For example If I have the following models, views and code in a template...
class news(models.Model):
type = models.ForeignKey(----) (charfield)
title = models.CharField(max_length=100)
published = models.DateTimeField(default=datetime.now)
summary = models.CharField(max_length=200)
def ----():
items = news.objects.all().order_by('-published')[:5]
return {'items': items}
{% if items %}
<ul>
{% for item in items|slice:":2" %}
<li>{{ item.title }}</li>
<li>{{ item.summary }}</li>
{% endfor %}
<ul>
{% endif %}
How would you go about displaying items only of a certain type. using the above template code.
e.g. display all items of only type = Worldnews.
I know this is usually achieved in views however I would like to know how this is achieved inside a template.
All help is greatly appreciated.