I want to do something like this:
Entries.objects.values('date.year','date.month')
but this line is not valid. How can I list blog entries by year,month and display them in template?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you set
in your view, you can display the months and years in the template using the ifchanged template tag.
Another useful Django queryset method for blog archives is dates.
For example
returns a
DateQuerySetofdatetime.datetimeobjects for each month that has Blog Entries. You can use this queryset in the template to create links to monthly archive pages.