diff options
| author | Loic Bistuer <loic.bistuer@sixmedia.com> | 2013-03-08 09:15:23 -0500 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2013-03-08 10:11:45 -0500 |
| commit | 6983a1a540a6e6c3bd941fa15ddd8cb49f9ec74e (patch) | |
| tree | e57559ebfd704705458e6e218dc1f3d868b2922c /docs/ref/contrib/admin | |
| parent | 477d737e1e6bdf93950c8a381906925c594fac2f (diff) | |
Fixed #15363 -- Renamed and normalized to `get_queryset` the methods that return a QuerySet.
Diffstat (limited to 'docs/ref/contrib/admin')
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 9a0f3ca7f8..ae2ee44601 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -703,7 +703,7 @@ subclass:: Only show the lookups if there actually is anyone born in the corresponding decades. """ - qs = model_admin.queryset(request) + qs = model_admin.get_queryset(request) if qs.filter(birthday__gte=date(1980, 1, 1), birthday__lte=date(1989, 12, 31)).exists(): yield ('80s', _('in the eighties')) @@ -1326,20 +1326,23 @@ templates used by the :class:`ModelAdmin` views: be interpreted as meaning that the current user is not permitted to delete any object of this type). -.. method:: ModelAdmin.queryset(self, request) +.. method:: ModelAdmin.get_queryset(self, request) - The ``queryset`` method on a ``ModelAdmin`` returns a + The ``get_queryset`` method on a ``ModelAdmin`` returns a :class:`~django.db.models.query.QuerySet` of all model instances that can be edited by the admin site. One use case for overriding this method is to show objects owned by the logged-in user:: class MyModelAdmin(admin.ModelAdmin): - def queryset(self, request): - qs = super(MyModelAdmin, self).queryset(request) + def get_queryset(self, request): + qs = super(MyModelAdmin, self).get_queryset(request) if request.user.is_superuser: return qs return qs.filter(author=request.user) + .. versionchanged:: 1.6 + The ``get_queryset`` method was previously named ``queryset``. + .. method:: ModelAdmin.message_user(request, message, level=messages.INFO, extra_tags='', fail_silently=False) Sends a message to the user using the :mod:`django.contrib.messages` @@ -1549,7 +1552,7 @@ adds some of its own (the shared features are actually defined in the - :attr:`~ModelAdmin.filter_vertical` - :attr:`~ModelAdmin.ordering` - :attr:`~ModelAdmin.prepopulated_fields` -- :meth:`~ModelAdmin.queryset` +- :meth:`~ModelAdmin.get_queryset` - :attr:`~ModelAdmin.radio_fields` - :attr:`~ModelAdmin.readonly_fields` - :attr:`~InlineModelAdmin.raw_id_fields` |
