django-guardian 1.0.4 documentation
Extends django.contrib.admin.ModelAdmin class. Provides some extra views for object permissions management at admin panel. It also changes default change_form_template option to 'admin/guardian/model/change_form.html' which is required for proper url (object permissions related) being shown at the model pages.
If this would be set to True, request.user would be used to filter out objects he or she doesn’t own (checking user field of used model - field name may be overridden by user_owned_objects_field option.
Please remember that this will NOT affect superusers! Admins would still see all items.
Just use GuardedModelAdmin instead of django.contrib.admin.ModelAdmin.
from django.contrib import admin from guardian.admin import GuardedModelAdmin from myapp.models import Author class AuthorAdmin(GuardedModelAdmin): pass admin.site.register(Author, AuthorAdmin)
Returns context dictionary with common admin and object permissions related content.
Returns form class for group object permissions management. By default AdminGroupObjectPermissionsForm is returned.
Returns object permissions for group admin template. May be overridden if need to change it dynamically.
If INSTALLED_APPS contains grappelli this function would return "admin/guardian/grappelli/obj_perms_manage_group.html".
Returns main object permissions admin template. May be overridden if need to change it dynamically.
If INSTALLED_APPS contains grappelli this function would return "admin/guardian/grappelli/obj_perms_manage.html".
Returns form class for user object permissions management. By default AdminUserObjectPermissionsForm is returned.
Returns object permissions for user admin template. May be overridden if need to change it dynamically.
If INSTALLED_APPS contains grappelli this function would return "admin/guardian/grappelli/obj_perms_manage_user.html".
Extends standard admin model urls with the following:
... above are standard, instance detail url (i.e. /admin/flatpages/1/)
Manages selected groups’ permissions for current object.
Manages selected users’ permissions for current object.
Main object permissions view. Presents all users and groups with any object permissions for the current model instance. Users or groups without object permissions for related instance would not be shown. In order to add or manage user or group one should use links or forms presented within the page.