Django

Code

Ticket #4908 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Error in tutorial part 4

Reported by: ubernostrum Assigned to: jacob
Milestone: Component: Documentation
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

tutorial04.diff (1.3 kB) - added by ubernostrum on 07/17/07 13:27:16.
Patch which fixes and clarifies the usage

Change History

07/17/07 13:27:16 changed by ubernostrum

  • attachment tutorial04.diff added.

Patch which fixes and clarifies the usage

07/17/07 16:36:45 changed by SmileyChris

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests changed.
  • needs_docs changed.

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.

(follow-up: ↓ 4 ) 07/17/07 21:31:57 changed 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.

07/17/07 21:39:18 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Unreviewed to Ready for checkin.

(in reply to: ↑ 2 ) 07/18/07 00:00:03 changed by John Shaffer <jshaffer2112@gmail.com>

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'),
)

07/25/07 20:42:47 changed 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.

08/19/07 10:08:48 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(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/Change #4908 (Error in tutorial part 4)




Change Properties
Action