Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 532407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:24:05+00:00 2026-05-13T09:24:05+00:00

I’m on my first Django blog and when trying to get the posts by

  • 0

I’m on my first Django blog and when trying to get the posts by year, month and day, using the built-in generic view from Django, but I don’t get proper results. (Sorry for my non-professional first question.. if someone knows what is the appropriate question, please let me know)

Well, I think it’s better to show you my configuration to make yourself a better picture:

Complete blog URLconf:

from django.conf.urls.defaults import *

from weblog.models import Entry

entry_info_dict = {
    'queryset': Entry.published,
    'date_field': 'pub_date',
    'template_object_name': 'Entry',
    }

urlpatterns = patterns('django.views.generic.date_based',
      (r'^$', 'archive_index', entry_info_dict, 'weblog_entry_archive_index'),
      (r'^(?P<year>\d{4})/$',
       'archive_year', entry_info_dict,
       'weblog_entry_archive_year'),
      (r'^(?P<year>\d{4})/(?P<month>\w{3})/$',
       'archive_month',
       entry_info_dict,
       'weblog_entry_archive_month'),
      (r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/$',
       'archive_day',
       entry_info_dict,
       'weblog_entry_archive_day'),
      (r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
       'object_detail',
       entry_info_dict,
       'weblog_entry_detail'),
)

urls.py:

urlpatterns = patterns('',
(r'^blog/', include('weblog.urls.entries')),
...
)

entry_archive_year.html:

            <h2>Archive for {{ year }}</h2>
            <ul>
                    {% for month in pub_date %}
                    <li>
                            <a href="/blog/{{ year }}/{{ month|date:"b" }}/">{{ month|date:"F" }}</a>
                    </li>
                    {% endfor %}
            </ul>

Supposing I have the following blog entry:

example.com/blog/2009/dec/18/test

and now request

example.com/blog/2009/

I get no objects, though when giving the full URL the post is shown.

I think Django is failing silently somewhere, though it’s in DEBUG mode, and I can’t figure out where.
I’d appreciate any support with this one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:24:05+00:00Added an answer on May 13, 2026 at 9:24 am

    The month information is stored in the context variable date_list, not pub_date.

    From the django docs for archive_year:

    Template context:

    In addition to extra_context, the
    template’s context will be:

    • date_list: A list of datetime.date objects representing all
      months that have objects available in
      the given year, according to queryset,
      in ascending order.

    The following should do the trick:

    {% for month in date_list %}
        <li>
            <a href="/blog/{{ year }}/{{ month|date:"b" }}/">{{ month|date:"F" }}</a>
        </li>
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.