Opened 4 years ago

Closed 4 years ago

Last modified 4 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.:

  • 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 krzysiumed 4 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 4 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:

  • 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 4 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 4 years ago by krzysiumed

comment:3 Changed 4 years ago by krzysiumed

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

comment:4 Changed 4 years ago by krzysiumed

  • Cc krzysiumed@… added

comment:5 Changed 4 years ago by jezdez

  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 4 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 4 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.

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