Created
November 28, 2011 06:15
-
-
Save gladson/1399330 to your computer and use it in GitHub Desktop.
fdsgdfgdf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| from calendar import month_name | |
| def mkmonth_lst(): | |
| if not Post.objects.count(): return [] | |
| year, month = time.localtime()[:2] | |
| first = Post.objects.order_by("created")[0] | |
| fyear = first.created.year | |
| fmonth = first.created.month | |
| months = [] | |
| for y in range(year, fyear-1, -1): | |
| start, end = 12, 0 | |
| if y == year: start = month | |
| if y == fyear: end = fmonth-1 | |
| for m in range(start, end, -1): | |
| months.append((y, m, month_name[m])) | |
| return months | |
| def month(request, year, month): | |
| posts = Post.objects.filter(created__year=year, created__month=month) | |
| return render_to_response("blog/list.html", dict(post_list=posts, user=request.user, | |
| months=mkmonth_lst(), archive=True)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment