Code

Opened 5 years ago

Closed 5 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: UI/UX:

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!

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by rmichael

  • Component changed from Uncategorized to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by mtredinnick

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

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.

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.