Opened 7 years ago

Closed 7 years ago

Last modified 7 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: UI/UX:

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 7 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 7 years ago by Matt McClanahan

Component: UncategorizedDocumentation
Triage Stage: UnreviewedAccepted

Changed 7 years ago by Tim Graham

Attachment: 12161.diff added

comment:2 Changed 7 years ago by Tim Graham

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:3 Changed 7 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

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

comment:4 Changed 7 years ago by Manuel Saelices

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