Opened 4 years ago

Closed 4 years ago

#12971 closed (invalid)

Generic View Tutorial contains broken / incorrect syntax

Reported by: quietlyconfident <dykema@…> Owned by: nobody
Component: Documentation Version: 1.1
Severity: Keywords: generic view tutorial
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The tutorial part 4 here: contains the following example (edited for brevity):

urlpatterns = patterns('',
    (r'^$', 'django.views.generic.list_detail.object_list', info_dict),

Of note, the 2nd argument, django.views.generic.... , is quoted as if it were a string. It's not and quoting it as such causes an error at runtime. I'm not precisely sure how to submit a patch for documentation, but for all four of those examples, the 2nd argument shouldn't be quoted, it should look like this:

urlpatterns = patterns('',
    (r'^$', django.views.generic.list_detail.object_list, info_dict),

And it would be even better IMHO if some of the fluff were taken out of that module name, by importing object_list and object detail from the proper module:


from django.views.generic.list_detail import object_list, object_detail

urlpatterns = patterns('',
    (r'^$', object_list, info_dict),

This last one seems to be the most readable.

Attachments (0)

Change History (1)

comment:1 Changed 4 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

You don't mention specifics of the "error at runtime" you see so I'm not sure what's gone wrong in your setup. Strings for the 2nd tuple item in a url pattern are valid, and consistent with how url patterns are specified throughout the tutorial. Callables are also allowed (see but not required.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.