Skip to content

Instantly share code, notes, and snippets.

@nefarioustim
Created September 30, 2009 08:44
Show Gist options
  • Save nefarioustim/197923 to your computer and use it in GitHub Desktop.
Save nefarioustim/197923 to your computer and use it in GitHub Desktop.
from django.conf.urls.defaults import *
from blog.models import Category, Post
post_info_dict = {
'queryset': Post.pub.all(),
'date_field': 'pub_date',
}
urlpatterns = patterns('blog.views',
(r'^$', 'post_index'),
(r'^(?P<slug>[-\w]+)\.html$', 'post_detail'),
(r'^categories/(?P<slug>[-\w]+)/$', 'category_detail'),
)
urlpatterns += patterns('',
(r'^comments/', include('django.contrib.comments.urls'))
)
urlpatterns += patterns('django.views.generic.simple',
(r'^archive/(?P<slug>[-\w]+)/$', 'direct_to_template', {'template': 'post_archive_cat.html'}),
)
urlpatterns += patterns('',
(r'^categories/$', 'django.views.generic.list_detail.object_list', {
'queryset': Category.objects.all()
}),
)
urlpatterns += patterns('django.views.generic.date_based',
(r'^archive/$', 'archive_index', post_info_dict),
(r'^archive/(?P<year>\d{4})/$', 'archive_year', post_info_dict),
# (r'^archive/(?P<year>\d{4})/(?P<month>\w+?)/$', 'archive_month', dict(
# post_info_dict.items()
# + {'month_format': '%B'}.items()
# )),
(r'^archive/(?P<year>\d{4})/(?P<month>\w+?)/$', 'archive_month', dict(
post_info_dict.items().append([('month_format', '%B')])
)),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment