Created
June 14, 2011 05:23
-
-
Save toast38coza/1024370 to your computer and use it in GitHub Desktop.
Django Admin: Limiting access to objects in the admin on an instance level
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from more_with_admin.examples import models | |
class DocumentAdmin(admin.ModelAdmin): | |
def queryset(self, request): | |
qs = super(DocumentAdmin, self).queryset(request) | |
# If super-user, show all comments | |
if request.user.is_superuser: | |
return qs | |
return qs.filter(added_by=request.user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From: http://www.ibm.com/developerworks/opensource/library/os-django-admin/index.html