Opened 16 years ago

Closed 16 years ago

#9915 closed (wontfix)

Docs for "Naming URL patterns"

Reported by: rmichael Owned by: nobody
Component: Documentation Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the short section "Naming URL patterns", here, the example is re-written as

urlpatterns = patterns('',
    url(r'^archive/(\d{4})/$', archive, name="full-archive"),
    url(r'^archive-summary/(\d{4})/$', archive, {'summary': True}, "arch-summary"),
)

Assuming I've understood correctly, I think it would be clearer if the second url() call also explicitly used the "name=" parameter, and also provided the extra dictionary of options as the final argument (for consistency with the earlier discussion on the same page). E.g.

urlpatterns = patterns('',
    url(r'^archive/(\d{4})/$', archive, name="full-archive"),
    url(r'^archive-summary/(\d{4})/$', archive, name="arch-summary", {'summary': True}),
)

(In fact, I'm not sure it's correct if written without the named parameter "name", e.g. without "name=...".)

If it's fine, and I have misunderstood, it would be nice if the documentation mentioned a short-hand is being used in the second url() call to eliminate my misunderstanding. :)

Excellent docs in general, thanks!

Change History (2)

comment:1 by rmichael, 16 years ago

Component: UncategorizedDocumentation

comment:2 by Malcolm Tredinnick, 16 years ago

Resolution: wontfix
Status: newclosed

Thanks for the idea, but I don't think we should change this. The documented examples are written the way they are intentionally: to reinforce that both named keyword arguments and positional arguments (in the four argument case) can be used. They are also deliberately showing variations in the number of arguments (e.g. you can use the name parameter without requiring the context dictionary).

Your rewrite, aside from being illegal Python syntax, doesn't seem to make things any clearer and actually makes things a little less clear, since it might make it appear that the argument always has to be called as a keyword argument.

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