Re: Auto-archive lists
Hi Everyone, Thanks really much for all those pointers! Templatetags are exactly what I wound up doing. RossP -- thanks for your blog and example download code -- saved me to see actual working stuff :) Cheers, Seemant --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Auto-archive lists
On 10/05/06 17:34, seemant wrote: > Hi All, > > So, on the right column of http://www.djangoproject.com/weblog/ that > page, we see an index of archived posts, going back 12 months or so. > > And so I thought I'd check out the template: > http://code.djangoproject.com/browser/djangoproject.com/django_website/templates/base_weblog.html > > but the template (and adrian's commit message) seem to imply that that > list is generated manually. Is there no construct in Django that will > auto-gen a link list like that? > I needed just that so I wrote a template tag for it [1]. Usage is like this: {% load archivedates %} {% get_archive_dates news.Entry pub_date as archive_dates %} {% if archive_dates %} News Archiv {% for archive in archive_dates %} {{ archive|date:"F Y" }} {% endfor %} {% endif %} [1] http://www.c-area.ch/code/django/templatetags/archivedates.py Hope that helps Steven --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Auto-archive lists
Hi Seemant, There's no single construct that would do all that for you. But there are a few handy ways that you could consider: 1. Pass the distinct list of months in 'extra_context' to the generic view date_based.archive_index and use that list in your template. 2. The generic view date_based.archive_year provides a date_list to your template -- it's a distinct list of months for the year. It can be used to build up a list on the right side panel. 3. Write a custom template tag to build up this list. I would personally go with this one for its DRY benefits. This article covers it very nicely: (http://www.rossp.org/blog/2006/jun/23/building-blog-django-4/) It also uses the same technique to show Tags on the right. -Rajesh --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Auto-archive lists
Hello seemant! On Thu, 05 Oct 2006 15:34:17 - you wrote: > > Hi All, > > So, on the right column of http://www.djangoproject.com/weblog/ that > page, we see an index of archived posts, going back 12 months or so. > > And so I thought I'd check out the template: > http://code.djangoproject.com/browser/djangoproject.com/django_website/templates/base_weblog.html > > but the template (and adrian's commit message) seem to imply that that > list is generated manually. Is there no construct in Django that will > auto-gen a link list like that? > > Thanks! I use that construction: http://www.djangoproject.com/documentation/templates/#regroup views.py --- months = Article.objects.dates('pub_date', 'month', 'DESC') dates = [{ 'year': m.year, 'month': m.month, 'count': Article.objects.filter(pub_date__year=m.year, pub_date__month=m.month) .count(), } for m in months] template - {% regroup dates by year as years %} {% for year in years %} {{ year.grouper }} {% for month in year.list %} {{ m onth.month|month }} ({{ month.count }}) {% endfor %} {% endfor %} -- ÷ÓÅÇÏ ÎÁÉÌÕÞÛÅÇÏ! çÒÉÇÏÒÉÊ greg [at] anastasia [dot] ru ðÉÓØÍÏ ÏÔÐÒÁ×ÌÅÎÏ: 2006/10/05 19:55 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Auto-archive lists
On 10/5/06, seemant <[EMAIL PROTECTED]> wrote: > but the template (and adrian's commit message) seem to imply that that > list is generated manually. Is there no construct in Django that will > auto-gen a link list like that? You could write a template tag to do it pretty easily, the database lookup would be Entry.objects.dates('pub_date', 'month', order='DESC') And you'd have a list of datetime objects corresponding to all the months in which there are entries. I think the reason the Django site doesn't use it is that A) that blog app was probably put together really quickly, and B) it was put together in the ancient dark ages before 0.90, when the 'dates' construct wasn't available (that was added in 0.95), and nobody's ever had the time to go back and fix that. -- "May the forces of evil become confused on the way to your house." -- George Carlin --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---