Author: russellm
Date: 2010-05-09 01:44:52 -0500 (Sun, 09 May 2010)
New Revision: 13170

Modified:
   django/trunk/docs/ref/contrib/admin/index.txt
Log:
Fixed #10712 -- Added documentation for the queryset() method on ModelAdmin. 
Thanks to mrts for the report, and timo for the patch.

Modified: django/trunk/docs/ref/contrib/admin/index.txt
===================================================================
--- django/trunk/docs/ref/contrib/admin/index.txt       2010-05-09 06:44:12 UTC 
(rev 13169)
+++ django/trunk/docs/ref/contrib/admin/index.txt       2010-05-09 06:44:52 UTC 
(rev 13170)
@@ -871,6 +871,20 @@
 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
 ~~~~~~~~~~~~~
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to