Opened 8 years ago

Closed 8 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.

Change History (1)

comment:1 Changed 8 years ago by Karen Tracey

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top