Django

Code

Ticket #9915 (closed: wontfix)

Opened 6 months ago

Last modified 6 months ago

Docs for "Naming URL patterns"

Reported by: rmichael Assigned to: nobody
Milestone: Component: Documentation
Version: 1.0 Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Change History

12/26/08 18:50:06 changed by rmichael

  • needs_better_patch changed.
  • component changed from Uncategorized to Documentation.
  • needs_tests changed.
  • needs_docs changed.

01/03/09 19:49:20 changed by mtredinnick

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

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/Change #9915 (Docs for "Naming URL patterns")




Change Properties
Action