Browse files

Fixed #10712 -- Added documentation for the queryset() method on Mode…

…lAdmin. Thanks to mrts for the report, and timo for the patch.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 3057a59 commit f9b75db90f606d03569edcfa71792d443d7545f4 @freakboy3742 freakboy3742 committed May 9, 2010
Showing with 14 additions and 0 deletions.
  1. +14 −0 docs/ref/contrib/admin/index.txt
@@ -871,6 +871,20 @@ return a subset of objects for this foreign key field based on the user::
This uses the ``HttpRequest`` instance to filter the ``Car`` foreign key field
to only the cars owned by the ``User`` instance.
+.. method:: ModelAdmin.queryset(self, request):
+The ``queryset`` method on a ``ModelAdmin`` returns a
+:class:`~django.db.models.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(self, MyModelAdmin).queryset(request)
+ if request.user.is_superuser:
+ return qs
+ return qs.filter(author=request.user)
Other methods

0 comments on commit f9b75db

Please sign in to comment.