Skip to content

Instantly share code, notes, and snippets.

@toast38coza
Created June 14, 2011 05:23
Show Gist options
  • Save toast38coza/1024370 to your computer and use it in GitHub Desktop.
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
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