Skip to content

Entries published on October 14, 2007

1 entry published on this date. See also: all entries published in October 2007, full archive.

Be careful with your URL patterns

Tonight in the Django IRC channel, someone stumbled across a seemingly-odd error when trying to use a generic view:

TypeError: object_list() got multiple values for keyword argument 'queryset'

The problem turned out to be the URL pattern which was routing to the generic view. Consider a simple example, as might be found in a weblog application:

from django.conf.urls.defaults import *
from weblog.models import Entry

info_dict = {
    'queryset': Entry.objects.all()

urlpatterns = ('',
    (r'^(index|weblog)/$', 'django.views.generic.list_detail.object_list', info_dict)

The idea here is that either of two different URLs — index/ or weblog/ — should route to the object_list generic view and display a list of entries, and at first glance this looks all right; it’s even somewhat clever in using the regular expression to handle two potential URLs instead of having two full patterns which essentially do the same thing. But …

Entry published October 14, 2007. Read full entry.