Django throws 404 at generic views
- by x0rg
I'm trying to get the generic views for a date-based archive working in django.
I defined the urls as described in a tutorial, but django returns a 404 error whenever I want to access an url with a variable (such as month or year) in it. It don't even produces a TemplateDoesNotExist-execption. Normal urls without variables work fine.
Here's my urlconf:
from django.conf.urls.defaults import *
from zurichlive.zhl.models import Event
info_dict = {
'queryset': Event.objects.all(),
'date_field': 'date',
'allow_future': 'True',
}
urlpatterns += patterns('django.views.generic.date_based',
(r'events/(?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/(?P<slug>[-w]+)/$', 'object_detail', dict(info_dict, slug_field='slug',template_name='archive/detail.html')),
(r'^events/(?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/(?P<slug>[-w]+)/$', 'object_detail', dict(info_dict, template_name='archive/list.html')),
(r'^events/(?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/$','archive_day',dict(info_dict,template_name='archive/list.html')),
(r'^events/(?P<year>d{4})/(?P<month>[a-z]{3})/$','archive_month', dict(info_dict, template_name='archive/list.html')),
(r'^events/(?P<year>)/$','archive_year', dict(info_dict, template_name='archive/list.html')),
(r'^events/$','archive_index', dict(info_dict, template_name='archive/list.html')),
)
When I access /events/2010/may/12/this-is-a-slug I should get to the detail.html template, but instead I get a 404. What am I doing wrong?