Opened 17 years ago

Closed 17 years ago

#4908 closed (fixed)

Error in tutorial part 4

Reported by: James Bennett Owned by: Jacob
Component: Documentation Version: dev
Severity: Keywords:
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

The sample URL configuration in part 4 of the tutorial uses the syntax of a url call, but without calling url (it passes in a final item to be the name of the URL).

Attachments (1)

tutorial04.diff (1.3 KB ) - added by James Bennett 17 years ago.
Patch which fixes and clarifies the usage

Download all attachments as: .zip

Change History (7)

by James Bennett, 17 years ago

Attachment: tutorial04.diff added

Patch which fixes and clarifies the usage

comment:1 by Chris Beaven, 17 years ago

Has patch: set

Are you sure it's an error?

In django.conf.defaults:

def patterns(prefix, *args):
    pattern_list = []
    for t in args:
        if isinstance(t, (list, tuple)):
            t = url(prefix=prefix, *t)

It looks to me like the tuple should work just as well.

comment:2 by James Bennett, 17 years ago

We had someone on IRC who was following the tutorial code exactly (double-checked by having him paste it) and it was erroring out saying there were too many arguments.

comment:3 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

in reply to:  2 comment:4 by John Shaffer <jshaffer2112@…>, 17 years ago

Replying to ubernostrum:

We had someone on IRC who was following the tutorial code exactly (double-checked by having him paste it) and it was erroring out saying there were too many arguments.

Are you 100% sure their checkout was up to date?

This code is working fine for us:

urlpatterns += patterns('satchmo.shop.views',
    (r'^cart/(?P<id>\d+)/remove/$', 'cart.remove', {}, 'satchmo_cart_remove'),
)

comment:5 by Gary Wilson, 17 years ago

Looking at the code, it looks like the tuple should still work, and others have confirmed this. So the real question here is do we want to recommend the use of url() over tuple? I would say yes.

comment:6 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [5946]) Used the url() function when adding a named URL pattern, mostly as an example of good practice and to introduce the function. Fixed #4908 (although it wasn't a bug).

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