Take the 2-minute tour ×

I've changed the language-code from en-us to es-ar and the url's began to fail. Example: When I click in "Agosto 2010" the URL is "http://mysite.com/weblog/2010/ago/" and the server couldn't finde the page. But if I browse "http://mysite.com/weblog/2010/aug/ the server finds and shows the page.


urlpatterns = patterns('django.views.generic.date_based',
         (r'^$', 'archive_index', entry_info_dict, 'coltrane_entry_archive_index'),
         (r'^(?P<year>\d{4})/$', 'archive_year', entry_info_dict, 
         (r'^(?P<year>\d{4})/(?P<month>\w{3})/$', 'archive_month', entry_info_dict, 


def render_month_links():
    return {
        'dates': Entry.objects.dates('pub_date', 'month'),


  {% for d in dates reversed %}
    <li><a href="/weblog/{{ d|date:"Y/b" }}/">{{ d|date:"F Y" }}</a></li>
  {% endfor %}
share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

The archive_month generic view takes a month_format parameter, which specifies a strftime directive (defaulting to '%b', for the locale's abbreviated month name) to parse the month value with.

The problem is that strftime uses the process's POSIX locale, which is not set by Django's own locale mechanism (which is what the date template filter uses). See this earlier question:

You could fix this in one of two ways:

  1. To keep using textual months, set Python's POSIX locale to match Django's LANGUAGE_CODE, for example by adding locale.setlocale(locale.LC_ALL, LANGUAGE_CODE) to your settings module. This should make strptime parse the same month abbreviations as produced by the date template filter. (Note: This assumes that you treat the installation's locale as static, and won't use something like LocaleMiddleware to change it dynamically.)
  2. To switch to numeric months (01–12), make the following changes:
    • archive_month view: (?P<month>\d{2}), and add month_format='%m'
    • template: {{ d|date:"Y/m" }}
share|improve this answer
Thanks Piet, that solved the problem! –  mxm Oct 13 '10 at 18:19
add comment

Your Answer


