diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-07-29 09:41:00 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-07-29 09:41:00 +0000 |
| commit | 2ccfb6d5c2ffb13ae3cb11a058ff574ab115518c (patch) | |
| tree | c1875a1bc27aeb9d683093db1e9c5565f7ac5c43 /docs | |
| parent | 5fffe574bdd624f69eb246ed0833d7a2aba16edb (diff) | |
Fixed #16101 -- Added parameters to SingleObjectMixin to override the name of the URL keyword arguments used for pk and slug. Thanks, Andrew Ingram and Julien Phalip.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16569 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/class-based-views.txt | 23 | ||||
| -rw-r--r-- | docs/releases/1.4.txt | 10 |
2 files changed, 29 insertions, 4 deletions
diff --git a/docs/ref/class-based-views.txt b/docs/ref/class-based-views.txt index 3448bbd6d7..2676c2cefc 100644 --- a/docs/ref/class-based-views.txt +++ b/docs/ref/class-based-views.txt @@ -136,6 +136,20 @@ SingleObjectMixin The name of the field on the model that contains the slug. By default, ``slug_field`` is ``'slug'``. + .. attribute:: slug_url_kwarg + + .. versionadded:: 1.4 + + The name of the URLConf keyword argument that contains the slug. By + default, ``slug_url_kwarg`` is ``'slug'``. + + .. attribute:: pk_url_kwarg + + .. versionadded:: 1.4 + + The name of the URLConf keyword argument that contains the primary key. + By default, ``pk_url_kwarg`` is ``'pk'``. + .. attribute:: context_object_name Designates the name of the variable to use in the context. @@ -146,10 +160,11 @@ SingleObjectMixin ``queryset`` is provided, that queryset will be used as the source of objects; otherwise, :meth:`~SingleObjectMixin.get_queryset` will be used. - :meth:`~SingleObjectMixin.get_object` looks for a ``pk`` - argument in the arguments to the view; if ``pk`` is found, - this method performs a primary-key based lookup using that - value. If no ``pk`` argument is found, it looks for a ``slug`` + ``get_object()`` looks for a + :attr:`SingleObjectMixin.pk_url_kwarg` argument in the arguments + to the view; if this argument is found, this method performs a + primary-key based lookup using that value. If this argument is not + found, it looks for a :attr:`SingleObjectMixin.slug_url_kwarg` argument, and performs a slug lookup using the :attr:`SingleObjectMixin.slug_field`. diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt index 43c9ae25c5..2723b42195 100644 --- a/docs/releases/1.4.txt +++ b/docs/releases/1.4.txt @@ -153,6 +153,16 @@ number of characters. Truncated strings end with a translatable ellipsis sequence ("..."). See the :tfilter:`truncatechars docs <truncatechars>` for more details. +Customizable ``SingleObjectMixin`` URLConf kwargs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Two new attributes, +:attr:`pk_url_kwarg<django.views.generic.detail.SingleObjectMixin.pk_url_kwarg>` and +:attr:`slug_url_kwarg<django.views.generic.detail.SingleObjectMixin.slug_url_kwarg>`, +have been added to :class:`django.views.generic.detail.SingleObjectMixin` to +enable the customization of URLConf keyword arguments used for single +object generic views. + CSRF improvements ~~~~~~~~~~~~~~~~~ |
