Opened 9 years ago

Closed 9 years ago

#4908 closed (fixed)

Error in tutorial part 4

Reported by: James Bennett Owned by: Jacob
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 9 years ago.
Patch which fixes and clarifies the usage

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by James Bennett

Attachment: tutorial04.diff added

Patch which fixes and clarifies the usage

comment:1 Changed 9 years ago by Chris Beaven

Has patch: set
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

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 Changed 9 years ago by James Bennett

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 Changed 9 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedReady for checkin

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

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 Changed 9 years ago by Gary Wilson

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 Changed 9 years ago by Malcolm Tredinnick

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