我已将语言代码从 en-us 更改为 es-ar 并且 url 开始失败。示例:当我单击“Agosto 2010”时,URL 为“http://mysite.com/weblog/2010/ ago /”,服务器找不到该页面。但是,如果我浏览“http://mysite.com/weblog/2010/aug/” ,服务器会找到并显示该页面。
网址.py:
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,
'coltrane_entry_archive_year'),
(r'^(?P<year>\d{4})/(?P<month>\w{3})/$', 'archive_month', entry_info_dict,
'coltrane_entry_archive_month'),
)
模板标签.py:
@register.inclusion_tag('coltrane/month_links_snippet.html')
def render_month_links():
return {
'dates': Entry.objects.dates('pub_date', 'month'),
}
month_links_snippet.html:
<ul>
{% for d in dates reversed %}
<li><a href="/weblog/{{ d|date:"Y/b" }}/">{{ d|date:"F Y" }}</a></li>
{% endfor %}
</ul>