Code

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#16653 closed Cleanup/optimization (fixed)

Document kwargs support for urlresolvers.resolve

Reported by: jedie Owned by: krzysiumed
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: krzysiumed@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The section "Reversing admin URLs" on the page https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#reversing-admin-urls should IMHO clarify that the parameters must be used as the keyword argument "args", e.g.:

diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index beff94e..d8cdd3c 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -1696,7 +1696,7 @@ accessible using Django's :ref:`URL reversing system <naming-url-patterns>`.
 The :class:`AdminSite` provides the following named URL patterns:
 
     ======================  ========================  =============
-    Page                    URL name                  Parameters
+    Page                    URL name                  args
     ======================  ========================  =============
     Index                   ``index``
     Logout                  ``logout``
@@ -1706,10 +1706,15 @@ The :class:`AdminSite` provides the following named URL patterns:
     Application index page  ``app_list``              ``app_label``
     ======================  ========================  =============
 
+Example go get the index page of the auth contrib app::
+
+    >>> from django.core import urlresolvers
+    >>> app_index_url = urlresolvers.reverse('admin:app_list', args=('auth',))
+
 Each :class:`ModelAdmin` instance provides an additional set of named URLs:
 
     ======================  ===============================================   =============
-    Page                    URL name                                          Parameters
+    Page                    URL name                                          args
     ======================  ===============================================   =============
     Changelist              ``{{ app_label }}_{{ model_name }}_changelist``
     Add                     ``{{ app_label }}_{{ model_name }}_add``

Attachments (1)

16653.diff (753 bytes) - added by krzysiumed 2 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 3 years ago by jedie

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Hm. We can use "Parameters" as args and as kwargs. So renaming "Parameters" to "args" ist wrong.

But for clarify it's IMHO usefull we have a example which used 'kwargs' (There is already an example with 'args').

I would suggest this:

diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index beff94e..e4ade64 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -1706,6 +1706,11 @@ The :class:`AdminSite` provides the following named URL patterns:
     Application index page  ``app_list``              ``app_label``
     ======================  ========================  =============
 
+Example go get the index page of the auth contrib app::
+
+    >>> from django.core import urlresolvers
+    >>> app_index_url = urlresolvers.reverse('admin:app_list', kwargs={'app_label': 'auth'})
+
 Each :class:`ModelAdmin` instance provides an additional set of named URLs:
 
     ======================  ===============================================   =============

comment:2 Changed 3 years ago by julien

  • Patch needs improvement set
  • Summary changed from Clarify "Reversing admin URLs" in docu... to Document kwargs support for urlresolvers.resolve
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Cleanup/optimization

I agree that kwargs support should be documented, but the best place for it probably is in https://docs.djangoproject.com/en/dev/topics/http/urls/#django.core.urlresolvers.reverse, since the admin doc already links to it anyway.

Changed 2 years ago by krzysiumed

comment:3 Changed 2 years ago by krzysiumed

  • Owner changed from nobody to krzysiumed
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:4 Changed 2 years ago by krzysiumed

  • Cc krzysiumed@… added

comment:5 Changed 2 years ago by jezdez

  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 2 years ago by timo

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

In [17517]:

Fixed #16653 - Added example of kwargs support for resolve(); thanks krzysiumed for the patch.

comment:7 Changed 2 years ago by timo

In [17518]:

Fixed #16653 - Added example of kwargs support for resolve(); thanks krzysiumed for the patch.

Backport of r17517 from trunk.

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.