Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#12161 closed (fixed)

Error in code example - Generic views (regular expression)

Reported by: infopams Owned by: nobody
Component: Documentation Version: 1.1
Severity: Keywords: regular-expression documentation generic-views
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

(at this page: http://docs.djangoproject.com/en/dev/topics/generic-views/)

This code example is nonfuctional:

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from mysite.books.views import about_pages

urlpatterns = patterns('',
    ('^about/$', direct_to_template, {
        'template': 'about.html'
    }),
    ('^about/(w+)/$', about_pages),
)

It should be like this:

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from mysite.books.views import about_pages

urlpatterns = patterns('',
    ('^about/$', direct_to_template, {
        'template': 'about.html'
    }),
    ('^about/(\w+)/$', about_pages),
)

In short: the token (w+) should be replaced for (\w+) in order to have de desired functionality

Attachments (1)

12161.diff (768 bytes ) - added by Tim Graham 15 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Matt McClanahan, 15 years ago

Component: UncategorizedDocumentation
Triage Stage: UnreviewedAccepted

by Tim Graham, 15 years ago

Attachment: 12161.diff added

comment:2 by Tim Graham, 15 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:3 by Adrian Holovaty, 15 years ago

Resolution: fixed
Status: newclosed

(In [12182]) Fixed #12161 -- Added escaping of a backslash in two generic-views.txt examples. Thanks, infopams

comment:4 by Manuel Saelices, 15 years ago

I think second changed line is a raw string, and don't must to be escaped

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