Code

Opened 7 years ago

Closed 7 years ago

#4908 closed (fixed)

Error in tutorial part 4

Reported by: ubernostrum 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 ubernostrum 7 years ago.
Patch which fixes and clarifies the usage

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by ubernostrum

Patch which fixes and clarifies the usage

comment:1 Changed 7 years ago by SmileyChris

  • 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 follow-up: Changed 7 years ago by 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.

comment:3 Changed 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:4 in reply to: ↑ 2 Changed 7 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 7 years ago by gwilson

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 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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).

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.