| 823 | .. method:: ModelAdmin.queryset(self, request): |
| 824 | |
| 825 | The ``queryset`` method on a ``ModelAdmin`` returns a |
| 826 | :class:`~django.db.models.QuerySet` of all model instances that can be edited |
| 827 | by the admin site. One use case for overriding this method is to show objects |
| 828 | owned by the logged-in user:: |
| 829 | |
| 830 | class MyModelAdmin(admin.ModelAdmin): |
| 831 | def queryset(self, request): |
| 832 | qs = super(self, MyModelAdmin).queryset(request) |
| 833 | if request.user.is_superuser: |
| 834 | return qs |
| 835 | return qs.filter(author=request.user) |
| 836 | |