Hi!

I created a simple view to display articles on my homepage. Here's the code:

def homepage(request):
    news = models.Section.objects.get(section = 'News')

    articles = models.Article.objects.exclude(section = news.id
).order_by("-pub_date")
    list_of_news = models.Article.objects.filter(section = news.id
).order_by("-pub_date")
    return render_to_response('home.html', {'news' : list_of_news[:4],
                                            'articles' : articles[:6]
                                            }


Now I want to make first news item a little bit bigger, and to place it in a
different form.
I am processing the list in a template this way:

{% for item in news %}
<div id="latest_article">
  <a href="{{ item.get_absolute_url }}"><img src="{% thumbnail
item.main_image 150x150 crop,upscale  %}" /></a>
  <a href="{{ item.get_absolute_url }}"><h1>{{ item.title }}</h1></a>
  <div id="latest_description">
    {{ item.short_description|truncatewords:60}}
  </div>
</div>

<hr id="heading" />

{% endfor  %}


Is there a way to check in the loop if it's a first item. And if so to
process it in a different way? Or do I have pass first article to template
separately?

Thanks,
Oleg

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to