Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16653 closed Cleanup/optimization (fixed)

Document kwargs support for urlresolvers.resolve

Reported by: jedie Owned by: Christopher Medrela
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.:

  • docs/ref/contrib/admin/index.txt

    diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
    index beff94e..d8cdd3c 100644
    a b accessible using Django's :ref:`URL reversing system <naming-url-patterns>`. 
    16961696The :class:`AdminSite` provides the following named URL patterns:
    16971697
    16981698    ======================  ========================  =============
    1699     Page                    URL name                  Parameters
     1699    Page                    URL name                  args
    17001700    ======================  ========================  =============
    17011701    Index                   ``index``
    17021702    Logout                  ``logout``
    The :class:`AdminSite` provides the following named URL patterns: 
    17061706    Application index page  ``app_list``              ``app_label``
    17071707    ======================  ========================  =============
    17081708
     1709Example go get the index page of the auth contrib app::
     1710
     1711    >>> from django.core import urlresolvers
     1712    >>> app_index_url = urlresolvers.reverse('admin:app_list', args=('auth',))
     1713
    17091714Each :class:`ModelAdmin` instance provides an additional set of named URLs:
    17101715
    17111716    ======================  ===============================================   =============
    1712     Page                    URL name                                          Parameters
     1717    Page                    URL name                                          args
    17131718    ======================  ===============================================   =============
    17141719    Changelist              ``{{ app_label }}_{{ model_name }}_changelist``
    17151720    Add                     ``{{ app_label }}_{{ model_name }}_add``

Attachments (1)

16653.diff (753 bytes) - added by Christopher Medrela 5 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 5 years ago by jedie

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:

  • docs/ref/contrib/admin/index.txt

    diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
    index beff94e..e4ade64 100644
    a b The :class:`AdminSite` provides the following named URL patterns: 
    17061706    Application index page  ``app_list``              ``app_label``
    17071707    ======================  ========================  =============
    17081708
     1709Example go get the index page of the auth contrib app::
     1710
     1711    >>> from django.core import urlresolvers
     1712    >>> app_index_url = urlresolvers.reverse('admin:app_list', kwargs={'app_label': 'auth'})
     1713
    17091714Each :class:`ModelAdmin` instance provides an additional set of named URLs:
    17101715
    17111716    ======================  ===============================================   =============

comment:2 Changed 5 years ago by Julien Phalip

Patch needs improvement: set
Summary: Clarify "Reversing admin URLs" in docu...Document kwargs support for urlresolvers.resolve
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/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 5 years ago by Christopher Medrela

Attachment: 16653.diff added

comment:3 Changed 5 years ago by Christopher Medrela

Owner: changed from nobody to Christopher Medrela
Patch needs improvement: unset
Status: newassigned

comment:4 Changed 5 years ago by Christopher Medrela

Cc: krzysiumed@… added

comment:5 Changed 5 years ago by Jannis Leidel

Triage Stage: AcceptedReady for checkin

comment:6 Changed 5 years ago by Tim Graham

Resolution: fixed
Status: assignedclosed

In [17517]:

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

comment:7 Changed 5 years ago by Tim Graham

In [17518]:

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

Backport of r17517 from trunk.

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